Author |
Topic |
|
spcom
11 Posts |
Posted - 05/02/2016 : 13:40:30
|
Hi,
is there a script to delete specific text from filename?
i oftenly have to extract tracks from a mkv file and after extracting them, that items contain a _track1, _track2, track3 ... in their filename. and sometimes i convert files and they have a (1) in the filename.
how can i delete any of that unwanted text from the filename with a script? it should search inside of the filename if any of the listed text exists and if so it should delete them automatically.
thank you
|
|
Rob
USA
2615 Posts |
Posted - 05/05/2016 : 01:10:33
|
Honestly, your best bet would probably be to use a utility designed to handle bulk file renaming. |
|
|
spcom
11 Posts |
Posted - 05/07/2016 : 02:44:55
|
the problem is, that i dont rename a lot of files at the same time. i have to rename them distributed throughout the day and mostly 1 to 2 file each time. |
Edited by - spcom on 05/07/2016 02:46:26 |
|
|
Rob
USA
2615 Posts |
Posted - 05/07/2016 : 19:07:48
|
One way would be to select the file (but would only be one at a time), then draw a gesture. Send the F2 key to put the file name in edit mode, then send CTRL+C. Then call acGetClipboardText() and use the various Lua string functions to check and parse the file name, followed by calling acSetClipboardText(cleaned_string), then sending CTRL+V to paste the new file name, then send the Enter key (~) to complete the rename operation. |
|
|
spcom
11 Posts |
Posted - 05/08/2016 : 05:50:43
|
because i am no programmer i had to search the internet about 3 hours to find a solution for the rename part of the action, but i think that i found a solution that is working:
acSendKeys("{F_2}(^c)")
str = acGetClipboardText() patterns = {"pattern1", "pattern2", "pattern3"} for i,v in ipairs(patterns) do str = string.gsub(str, v, "") end
acSetClipboardText(str) acSendKeys("(^v){ENTER}")
thank you for your help
|
|
|
|
Topic |
|
|
|