This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Lua Scripts
 General Action Scripts
 Delete Specific Text from Filename
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

spcom

11 Posts

Posted - 05/02/2016 :  13:40:30  Show Profile
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  Show Profile  Visit Rob's Homepage
Honestly, your best bet would probably be to use a utility designed to handle bulk file renaming.
Go to Top of Page

spcom

11 Posts

Posted - 05/07/2016 :  02:44:55  Show Profile
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
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/07/2016 :  19:07:48  Show Profile  Visit Rob's Homepage
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.
Go to Top of Page

spcom

11 Posts

Posted - 05/08/2016 :  05:50:43  Show Profile
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000