file to folder

Advanced Renamer forum
#1 : 12/09-24 10:13
Marco
Posts: 1
Good morning everyone,
I have some files e.g. : rl102c36.jpg and I would like to create and move each file to a nomenclar folder with the first 5 characters. In detail the file rl102c36.jpg will be placed in the folder RL102 in uppercase.
Can you help me?

Thank you very much for your cooperation.

Marco
#2 : 12/09-24 17:28
Delta Foxtrot
Posts: 364
Reply to #1:

Hi Marco, welcome,

If you want to keep the lowercase letters in the filename, I couldn't think of a straightforward way to do what you want natively. If you don't mind uppercase letters in the filename you can just use a New case method to uppercase the filename, and set the Batch mode to move with the Output folder field set to "<substr:1,5>" (no quotes).

If you want to keep the filename as original case, you can use this little script:
// -------------------------------------------------
const newname = item.name ;
const pathpart = item.name.substr(0,5) ;
const newpath = pathpart.toUpperCase() ;
item.newPath = item.path + newpath + "\\" ;
// -------------------------------------------------

Just put that in a Script method, save it in an .aren file, and it will do what you want (at least it did on my little test). :) Caveat: if there's a space in the fifth character position of a filename it will throw an error.

Screenshot: https://drive.google.com/file/d/1Ze6JooRDoqN4E8o pwrGppASaXLYpeZdd/view?usp=sharing

Best,
DF
#3 : 12/09-24 19:14
Delta Foxtrot
Posts: 364
Reply to #2:

Well, that was... interesting. Here's a script that will remove a space in the last position of the new path:

// -------------------------------------------------
const newname = item.name ;
const pathpart = item.name.substr(0,5) ;
const newpath = pathpart.toUpperCase() ;
if ( / $/.test(newpath) ) {
item.newPath = item.path + newpath.substr(0,4) + "\\" ;
} else {
item.newPath = item.path + newpath + "\\" ;
}
// -------------------------------------------------

A little safer, but if you have filenames shorter than 5 characters it will still probably error out. I can only think about this stuff for so long! :)

Best,
DF