Using 4 characters of folder name to move with contents

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

User avatar
Posts: 21
Joined: Mon Oct 17, 2016 1:41 pm
Location: USA

Using 4 characters of folder name to move with contents

Post by jaydoubleyou80 »

It's been a while since I needed to work on any of my scripts and I'm unfortunately pretty rusty.

I have a folder with as many as a few hundred sub folders all named like this: XXXXLABXX, where the first four characters are an item number. I need to file these in folders that either exist or don't without overwriting.

I want to scrape the first four characters of the folder name to be moved, find a matching folder in another directory (or create one if none exists), and then move the entire folder and its contents to the found or created location.

So far I have Folder.selectDialog for both origin and destination, but have had very little progress beyond that.

1234LAB56 folder > look for 1234 folder in destination, create if none > move 1234LAB56 folder to 1234 folder in destination. If 1234LAB56 already exists, ideally this would be reported at the end of the script so I can go in and manually move it.