Script to add text to file names

Discuss and share scripts and script files...
Post Reply
zer0
Posts: 2673
Joined: 19 Jan 2009 20:11

Script to add text to file names

Post 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 :)
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Script to add text to file names

Post 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);
Proud XYplorer Fanatic

zer0
Posts: 2673
Joined: 19 Jan 2009 20:11

Re: Script to add text to file names

Post 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:
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

Post Reply