0

I have a folder with a lot of subfolders named as dates.

1-1-2013, 1-1-2014, 1-1-2015, ...

I want to combine all the files in subfolders that match the same year into a new folder named after the year. So in this example, all the folders ending in the year 2013 (1-1-2013) would go into a folder named "2013" and so on.

How do I accomplish this with Automator?

2
  • Have you tried writing the script on your own? Did you run into any difficulty with it? There are a lot of wonderful resources on the Internet you can use to learn to help you accomplish it on your own.
    – Nimesh Neema
    Nov 2 '20 at 6:24
  • Your question has contradicting statements! You first say "I want to combine all the files in subfolders that match the same year into a new folder named after the year.", and then you say "So in this example, all the folders ending in the year 2013 (1-1-2013) would go into a folder named "2013" and so on.". So which is it!? Do you want to move the folders .e.g. 1-1-2013 into a folder named 2013, or do you want to move the files in folder 1-1-2013 into a folder named 2013!? Nov 2 '20 at 10:40
1

An easy way to do it would be use the Terminal, and write command as follows:

mkdir 2013

This create a folder named 2013 after the year.

mv *-2013/* 2013

This moves all the files from the folders those names end with "-2013" into the folder named 2013.

If you have a large number of years to do this for, consider using a simple bash script with a for loop - something like this:

for year in {2000..2020} 
do
  mkdir $year
  mv *-$year/* $year 
done
1
  • The OP has has contradicting statements! First said is "I want to combine all the files in subfolders that match the same year into a new folder named after the year.", and then said "So in this example, all the folders ending in the year 2013 (1-1-2013) would go into a folder named "2013" and so on.". So depending on what is actually wanted, *-$year/* may need to be changed to: *-$year Nov 2 '20 at 10:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .