Copying folders to dest where folder might already exist?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Hi there - I love Hazel and if I can figure out this one thing, I will be pleased as punch. Any help is greatly appreciated.

I use bittorrent a lot. Transmission downloads everything to my downloads folder, where Hazel promptly sorts everything out. For music files, the existing workflow is as follows:

Downloads Folder Rule:
1 - Copy all music files to my local Music folder

Local Music Folder Rules:
1 - Sort music files in subfolders, with the following structure: Authors/Albums/file.mp3
2 - Set color label for the top directory ("Authors," aka artists) to Red
3 - Move folders labeled Red to the Music folder on the NAS drive I have on my network

(I leave the originally downloaded files in my Downloads folder for seeding purposes.)

Now, the problem is that when I download an album from an artist I already have in my collection, it results in duplicate folders in my networked Music folder. For instance, if I already have Album 1 from Artist A on my hard drive, but then I download Album 2 from Artist A, when Hazel goes to move the folder to my hard drive, this is the result:

../Artist A/Album 1
../Artist A-1/Album 2

What I would like to happen is that if the Artist A folder exists in the destination directory, then only the Album folder is copied to that existing Artist A folder. And if the artist folder does not exist, then it is created.

Does that make sense? I'm not sure how well I'm articulating this. I'm guessing a simple script could handle this issue, but I'm not exactly sure where/how to start. Like I said, any help is greatly appreciated! TIA!
heylookltsme
 
Posts: 3
Joined: Thu Feb 26, 2009 6:44 pm

It looks like you want to "merge" the folders which is not supported currently (though it's being consider for 3.0). It's actually not supported in Finder either which causes confusion for people coming from Windows.

I think you can do what you want as follows. I'm making a couple assumptions here:

- You are using the local Music folder just as a temporary staging area before shipping it off to the NAS.
- You are sorting into subfolders based on the file's metadata.

If so, you could just do the following from your Downloads folder.

1. Copy file to the Music folder on the NAS drive.
2. Sort into subfolders based on metadata.

Maybe I'm missing something here so correct me if the above isn't what you need.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

That's what I thought too - but when I tried that I kept getting this error messge - "Sorting into subfolder failed. Could not move [file]. Source and destination folder are the same."

That's when the subfolder pattern is : Authors/Albums. Interestingly, when I tried to sort into a subfolder with a different pattern, like: Date Modified, then it works perfectly.

Am I maybe just doing something wrong?

Thanks for your help - greatly appreciated!

(both your assumptions are correct, btw)
heylookltsme
 
Posts: 3
Joined: Thu Feb 26, 2009 6:44 pm

Maybe the authors/album metadata is either not there or not indexed by Spotlight? If you do "Get Info" on the files in Finder, do you see that info under "More Info"? If not, then check your Spotlight privacy settings. There are also some commandline programs you can use to diagnose/tweak this so let me know if it gets to that point (and also tell me how proficient you are with using the commandline).
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

I don't see any information about authors/albums in Get Info and I checked my Spotlight settings and they look fine. The weird thing is the files I'm testing things with will sort into subfolders based on Authors/Albums just fine when they're in my Desktop or Downloads folder, but when they're in my remote Music folder, I get the error about the source and destination being the same. So I'm guessing that the metadata isn't the problem, though it is weird that I don't see that metadata when I do Get Info.

I'm pretty comfortable with the command line - I'm far from an expert or anything, but I use it often, so I'm keen on going that route if it'll help.

Thanks! :-)
heylookltsme
 
Posts: 3
Joined: Thu Feb 26, 2009 6:44 pm

Oh, I forgot this was on the NAS drive. Chances are Spotlight won't work there.

So, I guess it's back to using an intermediate folder. Unfortunately, this gets a bit trickier but try something like this.

Downloads:
- Copy to Music folder.
- Sort into subfolder based on Authors/Album

Music folder:
Rule 1:
If folder
- Run rules on folder contents (see the sticky article about subfolders in this forum)

Rule 2:
If music file
- Move file to NAS Music folder
- Sort into subfolder with a pattern: (source folder)
* Click on the (source folder) attribute and set it to "Show path from monitored folder"

That last part uses the relative path from the top level folder (in this cases, your Music folder) and recreates it at the destination. And if the folder structure already exists, it will just use it as is.

Try that and see if that does what you want. I'd test it on some test files first since it's a bit weird.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support