topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 3:15 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Move specific file types with original folder path included to another directory  (Read 5955 times)

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
I need to move all files of specific file-types from Folder A to Folder B and put them under the same path as they existed in A.  I need to do this on several filetypes but only one type at a time.  If the folder-path already exists in B, the file would just be added to it.  If it doesn't exist, the script would create it during the move.  It might be possible to do this with the right switches using Robocopy but I cant seem to find the right combintion of switches to work as needed.   The script needs to delete the files as they are moved to the new folder (Move insted of copy)
 
If there is a better program for doing this, I would be happy to use it.   I am hoping to be able to delete folder A when done as it should only contain 'trash'.  And folder B would contain only the file-types I need to keep with each in its original folder path.

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
Are you open to a pay solution?  I use Syncovery, and it can do exactly what you're saying.

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
"Are you open to a pay solution?  I use Syncovery, and it can do exactly what you're saying."   Thanks Wraith!

Good to see some many of the Oldtimers are still here.  Happy Holidays to ALL!    I don’t mind paying for it my Chri$tma$ present to the board will be going out soon as well   I assume the mfr. has a demo or trial so I can be certain before buying it can do what is needed.  The place I work has got to have some of the  WORST people i have ever run across in all my years in IT.  Most places would be GLAD to have someone tell the employees how to do what will work and NOT do what won't.  I swear they always try what WON'T first in an effort to prove me wrong.   They are so bad I don’t even know if I can feel sorry for them  Every joke you have EVERY read in a "IT repair manual giving real life examples  This is where they com from!  A disaster almost occurred the other day because someone could not find the "ANY" key in a new program we just bought.  As in press ANY KEY to continue?  She stopped evertything to file an Urgent Trouble Ticket an waited for me to get there   It took me a couple of minutes to get enough self-control to explain. They thought they had an "outdated keyboard" that was missing important keys.  Just like the (now Unlabeled)  START on Desktop or the mysterious Windows Key. 

I can see it is time for Computer-KLASS -01)

Back to the question though.  Just for my own knowledge , I thought this was an exact described example in Robocopy but i cannot find it now so I am glad to know therre IS a way out.
Will let you know you how Syncovery workes out

PS:  Update I FINALLY got Robocopy to work :)  perfectly at that.  I have been told that I can even shorten this but here is the Working Script to create an empty copy of a dir with only all paths


robocopy.exe /R:0 /W:0 "C:\SCRIPTS\A" "C:\SCRIPTS\B" /E /Z /Copy:DT /XF "*.???" /LOG:"C:\SCRIPTS\EMPTY.LOG"
where A is the original folder and B is the exact copy with no files in it
At this stage I alwasy add a pause when trying things i dont know for sure but all ran well and the log said no errors


Merry Christmas!
« Last Edit: December 16, 2018, 01:55 AM by questorfla »

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
PS:  Update I FINALLY got Robocopy to work   perfectly at that.  I have been told that I can even shorten this but here is the Working Script to create an empty copy of a dir with only all paths

Code: Text [Select]
  1. robocopy.exe /R:0 /W:0 "C:\SCRIPTS\A" "C:\SCRIPTS\B" /E /Z /Copy:DT /XF "*.???" /LOG:"C:\SCRIPTS\EMPTY.LOG"

where A is the original folder and B is the exact copy with no files in it
At this stage I alwasy add a pause when trying things i dont know for sure but all ran well and the log said no errors

Merry Christmas!


Merry Christmas to you too... and good job on the implementation!   :Thmbsup:  I use robocopy at work for a variety of tasks, but just rather kick back with Syncovery at home :)

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Wraith, I finally had time to test syncovery and it does work as advertised.  :)  The robocopy script I came up with does about half the job.  I will probably buy Syncovery abecasue it is the most well thought-out process I have seen for some time.   I can see where it (especially the schreduling part!) would be GREAT to have.  I might use it for what I need now as well -  if i can't get the robocopy switches in the correct order to work properly.  So far it does create the empty directory but i cant get it to move specific files.    I was hoping to find a simple way to manage this one task and feel Syncovery is almost like using a Shotgun to kill a fly  :)
Still, as you say, i think it will do the trick after i run a couple more tests so i am sure i know what is going on.  I can see many uses for it on much larger tasks i have to perform daily. 

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
I think if I ever had to do something that Syncovery didn't cover, that Robocopy would be easier to alter little aspects.  But so far, I haven't come up against anything that Syncovery didn't cover, so I just gave in and started using it pretty much exclusively.  I haven't messed with the scheduling yet.  But I've been thinking about it. 

My backup routine is (a) I have my documents in a couple of locations, depending on use.  My books and such are directly in my OneDrive directory.  The projects that I can't directly sync (Scrivener, Development) are in their own folder.  I sync those to my OneDrive directories when I work in those folders.  I also sync my OneDrive directories that I want to have a backup copy of to my NAS.  So my development work and writing are in 4 different locations (not counting the fact that I sync OneDrive to 3 other computers), and my other things are in 3 different locations.  I've never had to resort to my backups, but hopefully, that's good enough if I ever do...

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
You mean you Trust OneDrive?   :tellme:
That would be asking a lot for me to do.   Though I am sure it has gotten better since it first came out. 

One Question about Syncovery:  Do you know how it will handle cases where the files are buried beyond the Max_Path point?  I run into this a lot on these exact folders.  I am sure that a number of them are going to be like that.  Many Backup programs either Choke or return error codes for those files.  Yet they  really are there and can be opened, read, modified etc. by the programs (and people) that put them there. 
 
Files exactly like that are one of the main reasons for this project.  If i don't shorten the paths soon, every file in those folders will be in paths that cannot be backed up.  I have heard that MicroSoft has promised to open up the path lengths allowed to some really extreme number in a soon to be released version of Win 10.   And i think it can even be enabled now with some registry edits.  But as far as I can tell, the original Max_Path of 260 total is still the rule at this time.
 
Besides, the whole point is that people should be more careful and if I dont enforce some limiting factor, they end up copying a whole folder and all its paths under another top-level of folders adding even more complexity.  Searching for specific files in this mess cant be easy on the File Indexer Service.  This whole effort is to try to remove as many of those rediculously long file and folder names as possible

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member


questorgw

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
How about just collecting files, dumping them in  more logical and easy to backup folder structure and making symbolic links to these file, so the users have their (idiotically) deep layered folder structure they are accustomed to and you have it much easier doing the maintenance.

Just an idea, not sure if that is easily done on scheduled intervals. It sounds like your place of employment is one where you must make it easy for yourself to get things done.

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
You mean you Trust OneDrive?   

I haven't seen any reason not to, and it's helped me out.  For the price, I get 1TB and Office for 5 people.

One Question about Syncovery:  Do you know how it will handle cases where the files are buried beyond the Max_Path point?  I run into this a lot on these exact folders.  I am sure that a number of them are going to be like that.  Many Backup programs either Choke or return error codes for those files.  Yet they  really are there and can be opened, read, modified etc. by the programs (and people) that put them there. 

I don't have anything that deep that I can recall, unfortunately.  You could ask on the Syncovery site.  They've been responsive, even after the change from Super Flexible File Synchronizer.

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
I need to move all files of specific file-types from Folder A to Folder B and put them under the same path as they existed in A.

Code: Text [Select]
  1. robocopy.exe "C:\SCRIPTS\A" "C:\SCRIPTS\B" "*.docx" /MOV /R:0 /W:0 /E /Z /Copy:DT /LOG:"C:\SCRIPTS\EMPTY.LOG"


I have heard that MicroSoft has promised to open up the path lengths allowed to some really extreme number in a soon to be released version of Win 10.   And i think it can even be enabled now with some registry edits.  But as far as I can tell, the original Max_Path of 260 total is still the rule at this time.

If you want to bypass the max path length problem use extended-length path addressing, (eg. \\?\D:\somelongpath), maximum path length is then restricted to ~32,767 characters.

I have been told that I can even shorten this but here is the Working Script to create an empty copy of a dir with only all paths

Code: Text [Select]
  1. robocopy.exe "C:\SCRIPTS\A" "C:\SCRIPTS\B" /CREATE /E /XF "*.???" /LOG:"C:\SCRIPTS\EMPTY.LOG"

Since you're only recreating the directory tree you're not copying any files so /Copy:DT and /Z aren't used, you don't really need /R:0 or /W:0 either.

Remove /XF "*.???" and it'll create zero length files as well.

BTW, what happens if you have an extension longer than 3 characters, eg. .docx ?

Wouldn't /XF "*.*" be better ?

Also btw, before investing in commercial software to sync files/folders, Robocopy is quite capable of doing it either on the number of changes seen or a time interval.

Code: Text [Select]
  1. robocopy.exe "C:\SCRIPTS\A" "C:\SCRIPTS\B" "*.docx" /MOV /MON:3 /R:0 /W:0 /E /Z /Copy:DT /LOG:"C:\SCRIPTS\EMPTY.LOG"

Will check every minute to see if there has been at least 3 changes to the filesystem involving DOCX files.

Code: Text [Select]
  1. robocopy.exe "C:\SCRIPTS\A" "C:\SCRIPTS\B" "*.pdf" /MOV /MOT:3 /R:0 /W:0 /E /Z /Copy:DT /LOG:"C:\SCRIPTS\EMPTY.LOG"

Will check every three minutes to see if there has been any changes to the filesystem involving PDF files.

Check the /MON and /MOT options.
« Last Edit: December 18, 2018, 05:13 PM by 4wd »

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Merry Christmas and Happy New year to Everyone on the Board.  I was offline for the last part of the month (restrictions by the Wife in Charge) due to family all being together for first time in years. :)

To answer all the great replies though:
 
Shades.  You are always the one to [point out the logical fact-forward solutions.  To be honest, this is what the person who is doing this SHOULD be doing.  That was why I agreed to allow them to do it.
Instead, they created about 5 MORE top level folders with LONG names and used drag and drop to put all the other folders in those Five.  Things immediately went from "Worst to Worser"  :(  I had explained the problem and almost cried when I saw her solution.  Fortunately, I only allowed her to work with a copy of the original mess so..

Wraith:  Thanks for the comments on OneDrive.
I will take another look.  It has been a long time.  Every now and again, i peek at what has 'gathered itself" into my own one drive.  The other day, i tried to copy what was in it to another location and ran into a bunch of errors that basically said the files were not "available at  that time" .  Most of the errors were on larger files and none of these were anything i deliberately put into One Drive so i fully admit that I have not given it a fair test.  If it works for you, i should see what happens on another trial.   
The biggest problem we would have is constant flux.  We have  TON of storage with our Business OneDrive and the files would be constantly added, changed, moved etc.  That is going to need a ton of bandwidth. All that currently is all handled inhouse at gigabit speeds (or close) and I’m not sure how much of a hit we can take on our 30 MB (UP) Cable Pipe to the web.   Worth looking at if it works for you though.

And Lastly, 4WD!
😊 I Knew i could count on you having some great suggestions.  Seems like you must do a lot of the same things i have to do.  But you usually know all the best ways to do it.  I'm lookng forward to somebody coming out with an AI that can look at the problem and come up with best answer (one tha can be afforded by the little guys anyway, I'm sure Siri or Alexa could handle it with ease !)
At least you are patient enough to read the blasted HowTo's on Robo.  Some of your suggestions look Very Interesting though and I plan on trying them ALL out ASAP.

Wishing everyone a Great High-Tech New Year  for 2019. 

Again, thanks to all for the great suggestions

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
You might be running afoul of the on-demand file option.  I keep my files on the machines where I sync to in all cases.  In the settings dialog, you can find the option.

onedrive_settings.pngMove specific file types with original folder path included to another directory

My major problem that I've been running into with OneDrive was actually the reason I finally buckled down and turned off automatic updates to Windows 10.  Sometimes, when Windows 10 would do those, it would turn off OneDrive (I think it was a problem with copying a new version while the old version was still running).  Since I turned off automatic updates (WUB to the rescue), I haven't had that problem.

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
At least you are patient enough to read the blasted HowTo's on Robo.

robocopy /?

HowTo's not required  ;)