#1 : 11/04-25 17:47 Kenny
Posts: 1
|
I have several photos of soccer players. I have them named with their team first, then player name.
Examples: U14 Orange Owens_Billy Johnson.jpg U14 Orange Owens_Joe Gillant.jpg U14 Orange Owens_Kevin Durham.jpg U11 Red Reynolds_Jill Crabtree.jpg U11 Red Reynolds_Gabby Winthrop.jpg U11 Red Reynolds_Miller James.jpg I want to sort them by creating folders with the team name. I am using Batch Mode Rename and Method Script: folder = item.name.match(/^.*/); item.newPath = item.path + folder; This is creating a new folder with the team name, but doing it for every file. I need it to put all files that start with that team name into the same folder. Is this possible? Thank you! |
#2 : 11/04-25 19:45 Delta Foxtrot
Posts: 459
|
Reply to #1:
Hi Kenny, You don't need a script to do what you want. Without loading any methods into the method list, add your files and set the mode to either move or copy depending on your preference. I would also add the "New path" column to the file list so you can see where your files will be moved or copied. Unfortunately I'm unclear on if the team names are like"U11" or "U11 Red" or "U11 Red Reynolds"; I'm assuming the latter so I'll explain that first. In the "Output folder:" field, enter .\<substr:1:_> (no spaces) That's it. If the team name is "U11" enter: .\<substr:1: > and if it is "U11 Red" enter: .\<substr:1: > <substr: : > (the last two both have spaces internally but not at the ends) If I misunderstood please clarify, otherwise happy soccer-ing (or whatever you call it :) Best, DF |
#3 : 11/04-25 23:47 Delta Foxtrot
Posts: 459
|
Reply to #2:
Kenny, I realized you may be wanting to use a script just to learn more about scripting. If that's the case, here are two ways to do what you want. These both use the idea that the team name is like "U11 Red Reynolds". I leave it to you to change it if that's not what you are looking for. Script 1: name = item.newBasename ; path = item.path ; teamEndLoc = name.indexOf( "_" ) ; team = name.substr( 0, teamEndLoc ) ; item.newPath = path + "\\" + team ; return name ; Script 2: name = item.newBasename ; path = item.path ; team = app.parseTags( '<substr:1:_>' ) ; item.newPath = path + "\\" + team ; return name ; (Both these scripts can be shortened, at the expense of readability. You may want to investigate that further.) Best, DF |