3

I've a folder that has both image and video folders which I want to separate into separate folders based on the file type. I want this to be a script so that i can re run it when more files are imported

Current file structure

Currently images and videos are in a folder where they are combined by date

Images/
    2018-08/
          image1.png
          Video1.mp4
    2018-09/
          image1.png
          video1.mp4

Target Structure

After running the script I would like the folder structure and file names been retained with the point of having the images remain in the images structure and the videos being moved into a separate structure.

Images/
    2018-08/
          image1.png
    2018-09/
          image1.png
Videos/
    2018-08/
          Video1.mp4
    2018-09/
          video1.mp4

What i've tried so far

I've looked at the windows move command but it seems only to apply to a single folder.

Also I looked at then solution to How to copy files and keep the structure?. It almost solves my problem except I don't have a predefined list of files just pre defined extension and starting folder.

Some notes

  • The Higher folders e.g. Images and Videos will be predefined and are static
  • The sub-folders below images need to be automatically replicated
  • File names may duplicate between moves
6

Check out robocopy which is built in to Windows 7 and above.

It can move files and folders with a specific mask.

In your case, it should work using something like this: robocopy \images \videos *.mp4 /copyall /s /mov

I would recommend testing this on a few folders and files before running it on a large folder structure that could be really jumbled around, until you get the command just right.

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy

  • I tried /copyall and had an issue with the Auditing information permissions so tried /copy:DAT are there any concerns when not including S NTFS access control list (ACL), O Owner information, U Auditing information? – user1605665 Sep 3 '18 at 3:45
  • @user1605665 not really. Now that you mention it I seem to remember similar issues myself. This would be more important in a business network with different users on a server / computer. If they are just your files on your computer, it really doesn’t matter. The files inherit permissions from the parent folder anyways. – Appleoddity Sep 3 '18 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.