我有50个文件存储在50个目录中例如
d:RAWFILESAKshape.geojson
d:RAWFILESALshape.geojson
d:RAWFILESARshape.geojson
我希望所有文件都重命名为AK_shape.geojson、AL_shape.geojson,并复制到上面的1个目录中即中
d:RAWFILESAK_shape.geojson
d:RAWFILESAL_shape.geojson
d:RAWFILESAR_shape.geojson
我尝试过,但没有成功:
find "$PWD" -type f -name "shape.geojson" -exec bash -c ' DIR=$( dirname "{}" ); echo "{}" "$DIR"/"${DIR##*/}".geojson' ;
FIND: Parameter format not correct
这个更简单(而且快得多(的批处理文件做到了:
@echo off
cd d:RAWFILES
for /D %%d in (*) do move "%%dshape.geojson" "%%d_shape.geojson"
你能试试这个吗-
$PathRoot = "d:RAWFILES"
foreach($item in (Get-ChildItem $PathRoot))
{
$Prefix = $item.name
Get-ChildItem $PathRoot$Prefix | % {Rename-Item -Path $_.FullName -NewName $Prefix"_"$_}
Get-ChildItem $PathRoot$Prefix | Move-Item -Destination $($PathRoot)
}