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
Batch Rename - Parent Folder as part of file name
-
clarkedesign
- Posts: 71
- Joined: 14 Feb 2013 09:29
Batch Rename - Parent Folder as part of file name
Thanks,
Sean Clarke
Sean Clarke
-
highend
- Posts: 14946
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Batch Rename - Parent Folder as part of file name
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");
}
One of my scripts helped you out? Please donate via Paypal
-
clarkedesign
- Posts: 71
- Joined: 14 Feb 2013 09:29
Re: Batch Rename - Parent Folder as part of file name
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
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
Thanks,
Sean Clarke
Sean Clarke
-
highend
- Posts: 14946
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Batch Rename - Parent Folder as part of file name
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.
One of my scripts helped you out? Please donate via Paypal
XYplorer Beta Club