#1 : 23/05-25 15:32 SamsungGuy
Posts: 2
|
I'm getting an error when trying to post my message.
Incorrect string value: '\xF0\x9F\x8D\x92Sw...' for column 'comment' at row 1 So I will try to break down what what need help with. I was able to follow the following link: https://www.advancedrenamer.com/forum_thread?for um_id=12092 and was able to almost sort things out. I have many files with (99+) and time stamp XX_XX that I'm trying to remove and move to their own separate folder. There is many similar files and only the time stamp changes. 1st Attempt: Use Batch mode: Move Output folder: <Substr:1:"_"> Result: It creates all the folders but any file with a space after (99+) and before "_ Tango Live" will not move and cause an error. (99+) aier_o1p _ Tango Live 2024-11-05 09_41 (99+) aier_o1p _ Tango Live 2024-11-05 10_41 (99+) bye11 _ Tango Live 2024-05-11 09_56 (99+) Shcat _ Tango Live 2024-11-05 10_54 (99+) Shcat _ Tango Live 2024-11-07 11_54 (99+) emoji Swe Chrry emoji _ Tango Live 2024-11-05 08_33 Also many files names with emojis and special characters. Used Renaming methods to remove Pattern "(99+) " and "_ Tango Live". File are left looking aier_o1p 2024-11-05 09_41 and it create many folders for each date. I tried to modify the below code from https://www.advancedrenamer.com/forum_thread?for um_id=12092 folder = item.name.match(/^.*(?=_\d{8})/); item.newPath = item.path + folder; with folder = item.name.match(/^\(99\+\)\s*(.*?)\s*_ Tango Live|^(.*?)\s*_ Tango Live/); item.newPath = item.path + folder; That does seem to group all the similar files together and move them to their own group. But the folders look like (99+) bye11 _ Tango Live,bye11, (99+) emoji Swe Chrry emoji _ Tango Live,emoji Swe Chrry emoji, What is the best method to use to remove "(99+) " and time stamp "09_41" from each file and -> move them to their own separate folder such as bye11 or emoji Swe Chrry emoji without the file name repeating. I'm able to use \b\d{2}_(\d{2})\b to remove the timestamp but using another program. Thank you in advance. |
#2 : 23/05-25 18:29 Delta Foxtrot
Posts: 487
|
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
|
Reply to #2:
Thank you. For the most part this work. It's giving me some errors with file names with emojis and special characters. I ran the above and got the following errors during the script. Camila Emoji _ Tango Live 2024-11-19.mp4 (Emoji is a flower) Gentle & sweet emoji _ Tango live 2024-11-23 (emoji is a heart) Nikki emoji _ Tango Live 2024-06-19 (Emoji is a devil) The folders it creates is clipping some of the file names: Examples. @anywqer ---- > creates a folder named @anywq Emoji Emoji Angel Emoji Emoji ---- > creates a folder named emoji emoji Angel emoji (missing one emoji) Andrea!! ---- > creates a folder named Andrea without the !! Anetta ---- > creates a folder named Anet Any file name with just an emoji and no words, it doesn't create a folder or move files in them. I tried mixing what you said with the script I was using before: *************** folder = item.name.match(/^\(99\+\)\s*(.*?)\s*_ Tango Live|^(.*?)\s*_ Tango Live/); item.newPath = item.path + folder; ************** It removes the 99+, it removes the timestamp, appends number using Name collision rules moves all the files to their folder but folder names are too long. Example: @anywqer creates a folder named @anywqer _ Tango Live,,@anywqer and Andrea!! create a folder name Andrea!! _ Tango Live,,Andrea!! If you can direct me on the right path. I would appreciate your hard work. |
#4 : 27/05-25 19:22 Delta Foxtrot
Posts: 487
|
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: 487
|
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: 487
|
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 |