| 1. |
Solve : Batch file to remove old pgms on Flash Drive? |
|
Answer» Sorry, that title was hard to write, to explain what I'm wanting to do. Thanks for the suggestion.yeah why add a program in a less than a minute when you can write a program/script to do nearly the same thing over the span of a day or two.... Well, I guess I can think of several reasons... Robocopy MAKES this fairly simple. you can use a /PURGE switch to delete files that aren't in source from the destination. I'm sure the functionality could be made into a batch file if needed for XP or earlier. I won't be the one writing it, though I was just looking for some help, not a verbal Reprimand. I thought this was the DOS section. Guess I was wrong. I'll look for help elsewhere. My post was just an alternative suggestion as i know that utility works great and I don't know much batch. I understand where you're coming from though and hopefully someone is able to help.TheShadow, Often there are many piratical solutions to a problem. Yes, this is the DOS section, but it is generally understood that a windows solution may be offered. Few are really using MS-DOS on a PC. Use pf 'RoboCopy' is along the spirit of a command line job. Quote Robocopy, or "Robust File Copy", is a command-line directory replication command. It has been available as part of the Windows Resource Kit starting with Windows NT 4.0, and was first introduced as a standard feature in Windows Vista and Windows Server 2008. The command is robocopy.IMHO the suggestion of using Photocopy fills the requirement you specified. Photocopy, or even Robocopy does not do what I want. I'm sorry for wasting everyone's time. Moderator.. Please close this thread. I'm done here. This is called mirroring, or one-way sync. The syntax is like this for Robocopy: Robocopy [source] [target] /MIR [source] is the reference folder (or root of a folder tree) [target] is the folder (or root of a folder tree) you want to keep up-to-date by reference to [source] Quote I'd now like to write a batch file, to do my Flash Drive cleanup for me, by comparing what's in my "Output" folder Assuming your 'Output' folder is E:\Output and your pen drive is drive N the following should make the pen drive exactly like the Output folder. Robocopy E:\Output N:\ /MIR If the pen drive was blank, the first time you ran that command, it would create, on the pen drive, a copy of whatever was in E:\Output, including any subfolders and their contents. If the pen drive was not blank, any files or folders not in E:\Output would be removed. If you then removed a file or folder from E:\Output or a subfolder below it, then ran it again, then the corresponding items would be removed from pen drive N:\ If you added a file or folder to E:\Output and ran the command, then those items would be added to pen drive N:\ If you edited or updated a file in E:\Output or its tree, it would be detected and would replace a file of the same name in the same place on N:\ I just tested this on a hard drive folder (source) and pen drive (target) and as far as I can see it does what you were asking for, TheShadow, so I'd be interested to hear why it doesn't do what you want, so I could suggest a modification or some other command line solution. Quote from: TheShadow on June 03, 2013, 12:39:34 PM Photocopy, or even Robocopy does not do what I want. Odd. when I did Robocopy /? I got the opposite impression. You have two folders and you want to remove files not present in A that are present in B. PURGE can be used for this. If you want to sync the entire folder (add new files and delete ones not present in the source) there is also the /MIR switch noted by Salmon Trout. Unless of course you aren't after the desired functionality at all and are focussed on having some sort of batch file for this purpose for whatever reason.Quote from: TheShadow on June 03, 2013, 09:05:19 AM I keep my Output directory up to date, almost daily, and I remove old, out of date, entries (files). But my Yeah, you want the /MIR function of robocopy. This is extremely powerful and also destructive if you use the wrong folders. Be careful. "N:\data folder" is the target drive Code: [Select]@echo off robocopy "E:\output folder" "N:\data folder" /FFT /R:0 /MIR /NP /FP /NDL /NJH /NJS Quote from: foxidrive on June 04, 2013, 02:10:01 AM Yeah, you want the /MIR function of robocopy.Good advice foxidrive! I normally throw a '/nocopy' switch onto the command line when testing a Robocopy script prior to full implementation. Thanks Ocalabob - I didn't know about the /nocopy switch. It goes to show how some things don't sink in even when when you read about them.I think the OP decided to take his ball home. It's likely that he got the replies by email, and found out the info, even if he doesn't want to play. |
|