Page 1 of 1

Script to add text to file names

Posted: 19 Feb 2009 00:11
by zer0
A small request, if I may, ladies and gentlemen.

I need a script that takes filenames of selected files (including extension), copies those filenames (not files themselves) to clipboard and adds a preset (aka hardcoded) bit of text to the beginning of every filename in clipboard. Example, I have files called file1.txt, file2.txt and file3.txt selected in a folder. Upon applying this script, assuming hardcoded preset is "temp-", the clipboard will have the following:

Code: Select all

temp-file1.txt
temp-file2.txt
temp-file3.txt
Having had a look at the list of scripting commands, I literally don't know where to start so I'm hoping someone will be able to help me. Thanks a lot guys :)

Re: Script to add text to file names

Posted: 19 Feb 2009 00:31
by jacky
Something like this maybe...

Code: Select all

  input $prefix, "Enter prefix", "temp-";
  copytext report("$prefix{Name}<crlf>", 1);
Or if you don't want to be asked for the prefix each time:

Code: Select all

copytext report("temp-{Name}<crlf>", 1);

Re: Script to add text to file names

Posted: 19 Feb 2009 11:40
by zer0
Thank you very much, the version with prefix hardcoded did the trick. Is there no end to what scripting can do with files and your knowledge of it? :lol: