Move Files to New Folder Using Filename

I want to move several hundred files from one hard drive to another while adding a new sub-directory. For example I have the file '3 Days to Kill (2014).avi' currently located in the directory Movies on a drive named Movies 1... ergo

/volumes/Movies 1/Movies/3 Days to Kill (2014).avi

I want it moved to:

/volumes/Media/Movies/3 Days to Kill (2014)/3 Days to Kill (2014).avi

My attempts have failed and I need some advice. Here is my latest macro:

Although I have tried several iterations, nothing seems to work.

Another situation to know about is that some files have the same name with differing extensions. For example I may have:

3 Days to Kill (2014).avi
3 Days to Kill (2014).srt

Both files should end up in the same sub-directory.

I would appreciate some help and advice.

Thanx

Ken

For your first issue, since that directory no doubt doesn’t exist on your target drive, you need to have an action to create it first. Set it up like this and if there's no directory (which there probably won't be) then it will create one using the file's name supplied by your variable FileName. Then put the move action after the If action, but not in it.

For your second issue, once the directory has been created, any other files with the same name would be put in the same directory since they're supplying the same FileName variable.

Thanx, that helps, however I still have problems. Now the directories are being created, but the files are not getting moved. I have also tried the following:

Your screenshot is cut off but it looks like you're trying to move a file using the FileName variable, but it does not include the extension. You need to either use a variable that includes the extension, append it manually, or set the extension as another variable and append that to the FileName variable in the move action.

Sorry it was cut off, below is the ending of the macro. I don't understand why it would be necessary to perform anything pertaining to the extension because my Display Text clearly shows that the FileName variable includes the extension. Here is a screenshot of an example Display Text:

...and the end of the macro:

True, but you’re not using your display name variable to move the file. You’re using the FileName variable which doesn’t include the extension. Try including the extension or using the display name variable and see what happens. :wink:

Hey Guys,

Unless you're renaming a moved item, you don't need the item name in the destination path:

Move- Copy- or Trash a File.kmactions (525 B)
Keyboard Maestro Export

@Paxapunch – Hey Ken,

When asking for help with macros please post actual, testable macros and not just pictures.

You'll get better and more accurate help when people can actually test your work without having to reinvent the wheel.

Take Care,
Chris

(Keyboard Maestro Moderator)

1 Like

Thanx Chris... Like this?

Make Movie Sub-Directory & Move Movie File.kmmacros (24.0 KB)
image

1 Like

Latest try by @Paxapunch:

Make Movie Sub-Directory & Move Movie File.kmmacros (24.4 KB)

Hey Ken,

The only problem – I think...

You had incorrect case in this action:

image

%variable%File% should be %Variable%File%


Point to note for future reference:

You should be aware that Keyboard Maestro won't make intermediate directories if they don't exist.

So your Movies folder must already exist in order for you to create a new folder in it and then move the movie file.

-Chris

Thanx... Case correction fixed the situation!

2 Likes

@Paxapunch looks like Chris (@ccstone) got you up and running!

@ccstone nice catch on the lowercase v in variable, I missed that completely!

-the other, not near as smart Chris :sweat_smile:

Yes, thanx… I am now a happy camper!