#1 : 23/05-25 15:32 SamsungGuy
Posts: 2
|
.
|
#2 : 23/05-25 18:29 Delta Foxtrot
Posts: 500
|
Reply to #1:
Hi Sam, [Note: I'm going to use quotes around phrases below to show spaces; copy the phrases without the quotes if you choose to use this material.] Break down your changes to separate methods. First remove the "(99+)"; if it's ALWAYS exactly that just use a Remove pattern method thusly: Pattern: "(99+) " [Note the space after. Otherwise you get a space at filename start.] You can generalize this is several ways, using regular expressions. For instance: Pattern: "^\(\d{1,3}.\)[ \._]" [Using regular expressions, this means ^ means start of filename \( matches a paren open \d{1,3} matches any 1- to 3-digit number . matches any one character \) matches paren close [ \._] matches only a space, period, or underscore after the preceding phrase Next, the timestamp. Use a Remove pattern method like: Pattern: " \d\d_\d\d$" [Make sure to include the space before the timestamp] Case: unchecked Use regular expressions: CHECKED Apply to: Name [Note 2: I'm not sure how you want to handle multiple files with the same name; just choose a Name collision rule that works for you] Assuming everything works for you up to this point, you can now move the files to a new folder. Try this script: //---------------- name = item.newBasename; pnameLoc = name.indexOf( ' _' ) ; pname = name.substr( 0, pnameLoc-2 ) ; item.newPath = item.path + "\\" + pname ; //---------------- [Hint: it worked for me using your filenames... :) Just make sure there's a space before the underscore in the "indexOf" expression; windows doesn't like spaces at the end of foldernames.] EDIT: In case I wasn't clear, you just need to use two "Remove pattern" methods followed by a "Script" method, all in one batch. Also, the batch mode above the ARen menu needs to remain "Rename", NOT copy or move. END EDIT |
#3 : 27/05-25 13:06 SamsungGuy
Posts: 2
|
.
|
#4 : 27/05-25 19:22 Delta Foxtrot
Posts: 500
|
Reply to #3:
I apologize, when creating the message above I managed to insert my original try at the script instead of the one where I removed the "-2" (which as you discovered chops off two characters in the foldername). This is what I meant to insert: name = item.newBasename; pnameLoc = name.indexOf( ' _' ) ; pname = name.substr( 0, pnameLoc ) ; item.newPath = item.path + pname ; EDIT Best, DF |
#5 : 27/05-25 20:04 Delta Foxtrot
Posts: 500
|
Reply to #4:
The script won't work if there's no <space><underscore> in the filename, so "all emojis" would generate a zero-length pname var (so the path stays the same). For some reason cloudflare is blocking me from adding a fix for that, so just add an if statement that checks if the new var pname is zero-length; if it is use some OTHER method to create the new foldername part. Good luck! DF |
#6 : 28/05-25 01:53 Delta Foxtrot
Posts: 500
|
Reply to #5:
It's several hours later; I'm going to see if Cloudflare will let me post an example fix for the "all emoji" problem. If I understand the problem correctly. :) This version checks to see if pname.length is zero. If yes, it measures the length of name; if over 10 it uses the first 10 characters as foldername, otherwise it uses the full name as foldername. // -------------- name = item.newBasename; pnameLoc = name.indexOf( ' _' ) ; pname = name.substr( 0, pnameLoc ) ; if ( pname.length == 0 ) { nameLen = name.length ; if ( nameLen >= 10 ) { pname = name.substr( 0, 10 ) ; } else { pname = name ; } } item.newPath = item.path + pname ; // -------------- I hope this does approximately what you want, and I also hope Cloudflare doesn't kick me to the curb again! Best, DF |