Page 1 of 1
renaming files with text file contents
Posted: 31 Jul 2019 05:42
by kotlmg
hello sir,
i want to rename only all file names not extensions in the folder with text file containg names.
example : folder has files unnamed.mp4, unnamed 1.mp4 and unnamed 3.mp4
text file has contents as
grammar usage
verb basics
all about modals
is it possible with script?
Re: renaming files with text file contents
Posted: 31 Jul 2019 05:43
by kotlmg
files should be named in chronological order.
after execution of script, file names should be
grammar usage.mp4
verb basics.mp4
all about modals.mp4
Re: renaming files with text file contents
Posted: 31 Jul 2019 09:24
by bdeshi
Code: Select all
$txt = inputfile(<curpath>,, "Select file with expected filenames");
$dir = inputfolder(<curpath>, "Select folder with files to rename");
tab("new", "$dir");
sortby "m", "a"; //sort by modified, descending
$names = replace(formatlist(readfile($txt), 'et', <crlf>), <crlf>, "|");
$items = listpane('a', "*.mp4", 1+4, "|");
rename "l", $names, "p", $items;
Try this script.
It asks you to first select a txt file containing expected file names per line, and then to select the folder that contains the mp4 files.
then it opens a tab to that folder, sorts files by
Modified, Ascending, (ie, the lastest modified file is at the bottom), and renames serially according to the txt content. You will get a prompt before the rename is applied.
To sort descending (so that latest files are at the top), change the "a" in
sortby "m", "a"; to a "d".
To sort by created date instead of modified, change the "m" in
sortby "m", "a"; to a "c".
No validation is done on the text content. You should make sure the text file only contains valid file names without duplication or other issues.
Re: renaming files with text file contents
Posted: 31 Jul 2019 09:28
by yuyu
This can be done also without scripting.
Sort your files chronologically and select them.
Then File>Rename Special>Edit Item Names... and paste text file contents to the box. Rename.
After that: File>Rename Special>Set Extension... mp4.
Re: renaming files with text file contents
Posted: 31 Jul 2019 16:30
by kotlmg
thanks a lot. both the code and non script solutions are working fine.