Page 1 of 1
Batch Rename - Parent Folder as part of file name
Posted: 13 Mar 2015 10:57
by clarkedesign
Hi,
Does anyone know a way that I can batch rename a whole heap of files I have in multiple folders.
I'd like to rename the individual files using the parent (containing) folder as part of the new file name.
so /parent-folder/015.jpg becomes /parent-folder/parent-folder-015.jpg
Re: Batch Rename - Parent Folder as part of file name
Posted: 13 Mar 2015 11:22
by highend
Select the files to be renamed and execute this script...
Code: Select all
setting "BackgroundFileOps", 0;
$curBase = gettoken("<curpath>", -1, "\");
foreach($file, "<get SelectedItemsPathNames |>") {
$newName = $curBase . "-" . getpathcomponent($file, "file");
renameitem($newName, $file, , "-01");
}
Re: Batch Rename - Parent Folder as part of file name
Posted: 13 Mar 2015 12:33
by clarkedesign
thanks for this - but cannot get it to work.
I select the files, then choose Scripting / Run Script...
Paste in the script, click OK
The files are not renamed - I get a popup on-screen showing the script, that's all
Re: Batch Rename - Parent Folder as part of file name
Posted: 13 Mar 2015 12:56
by highend
I guess you didn't indent the lines that you've pasted. Each line (apart from the first) must be indented by at least one space or one tab.