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
-
highend
- Posts: 14940
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
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
-
galtar53
- Posts: 18
- Joined: 19 Nov 2019 16:33
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
-
highend
- Posts: 14940
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
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
XYplorer Beta Club