Hello everyone, I want to add the directory name to the name of the files. see the attached example.
cordially
rename files belong to directories
Re: rename files belong to directories
There is no attached example...
Code: Select all
$items = <get selecteditemspathnames <crlf>>;
foreach($item, $items, <crlf>, "e") {
renameitem(gpc($item, "base") . " [" . gpc($item, "component", -2) . "]", $item);
}
One of my scripts helped you out? Please donate via Paypal
Re: rename files belong to directories
it's wonderful but I wanted to do this on several directories at the same time, adding their names to the prefix of each file inside without opening the directory. while selecting the directory only.
thank you very much
thank you very much
Re: rename files belong to directories
Code: Select all
$folders = <get selecteditemspathnames <crlf>>;
foreach($folder, $folders, <crlf>, "e") {
if (exists($folder) != 2) { continue; }
$base = gpc($folder, "component", -1);
$files = listfolder($folder, , 1, <crlf>);
foreach($file, $files, <crlf>, "e") {
renameitem($base . " - " . gpc($file, "file"), $file);
}
}
One of my scripts helped you out? Please donate via Paypal