Bold_Fortune Posted April 21, 2005 Share Posted April 21, 2005 I have a script for a batch file which I use quite often. This batch file will "move" (not delete) files I select from a folder to a backup folder on C:\ Maybe someone can help me modify it a little.I would like to be able to move a bunch of files at one time from a folder, while leaving the few files I want to keep in the folder.For example, with the inf folder (C:\WINDOWS\inf). I would like to be able to move all the inf files I don't want, and just keep the few I do want, without having to write in every inf file I don't want.(Did I explain that right?) I guess I'm asking, can this script be modified to keep a few files in a folder, and move all the others? See, I want to move 600 files, and keep about 30 files, but I'd rather type in the names of 30 files, than 600 files.------------------------------------------------- IF NOT EXIST "c:\backup\WINDOWS\system32" md c:\backup\WINDOWS\system32 MOVE c:\WINDOWS\system32\6to4svc.dll c:\backup\WINDOWS\system32\ MOVE c:\WINDOWS\system32\aaaamon.dll c:\backup\WINDOWS\system32\ MOVE c:\WINDOWS\system32\acledit.dll c:\backup\WINDOWS\system32\ MOVE c:\WINDOWS\system32\admparse.dll c:\backup\WINDOWS\system32\-------------------------------------------------Edited by un4given1: Please remember to use CODE tags. Link to comment Share on other sites More sharing options...
Martin Zugec Posted April 21, 2005 Share Posted April 21, 2005 Have a look at robocopy from resource kit, it is exactly what you are looking for. Link to comment Share on other sites More sharing options...
Bold_Fortune Posted April 21, 2005 Author Share Posted April 21, 2005 Thanks, soulin. Robocopy sounds interesting, but I was really hoping for a simple modification to the batch file above. If it can be done. Link to comment Share on other sites More sharing options...
un4given1 Posted April 21, 2005 Share Posted April 21, 2005 Remember, use CODE tags when posting code. Thank you. Link to comment Share on other sites More sharing options...
Bold_Fortune Posted April 21, 2005 Author Share Posted April 21, 2005 Sorry, un4given1, I don't know how to do to that. Never done it before, I guess. Link to comment Share on other sites More sharing options...
Bold_Fortune Posted April 21, 2005 Author Share Posted April 21, 2005 Maybe this will help. If I make the batch file to move all files (*.*) is there a way to protect and leave alone individual files?Like say I wanted to protect and leave alone "layout.inf".Could I insert layout.inf in some way to protect it and leave it in the folder?IF NOT EXIST "c:\backup\WINDOWS\inf" md c:\backup\WINDOWS\infMOVE c:\WINDOWS\system32\*.* c:\backup\WINDOWS\system32\(un4given1, sorry if this doesn't show up in code tag. I just don't know how to do that yet.) Link to comment Share on other sites More sharing options...
jdoe Posted April 21, 2005 Share Posted April 21, 2005 You can move your 30 files to a temp folder, do what you what in the folder you're working on and then move back your 30 files to the original folder.But you'll have to type the 30 files name. Link to comment Share on other sites More sharing options...
Bold_Fortune Posted April 21, 2005 Author Share Posted April 21, 2005 Thanks, jdoe. That's what I've been doing.You know, I have this Temp File Cleaner named, HDValet. You can configure it with the *.* command and point it toward a folder, but at the same time, you can protect certain files with it.That tells me there has to be a way of doing it. I'll keep looking. Thanks, all, for your help. Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 21, 2005 Share Posted April 21, 2005 Try This Then For Cmdcopy C:\backup\WINDOWS\*.inf c:\backup\WINDOWS\system32\Move C:\backup\WINDOWS\*.inf c:\backup\WINDOWS\system32\VBS Script MoveSet Shell = CreateObject("Shell.Application")set Folder = Shell.NameSpace( "c:\backup\WINDOWS\system32\") if not Folder is nothing Then Folder.MoveHere( "C:\backup\WINDOWS\*.inf") end IfVBS Script CopySet Shell = CreateObject("Shell.Application")set Folder = Shell.NameSpace( "c:\backup\WINDOWS\system32\") if not Folder is nothing Then Folder.CopyHere( "C:\backup\WINDOWS\*.inf") end IfBlue Change To Match Your Computer LocationGreen Is Just Asking To Keep The Test FolderOrange Is The Script Checking To See If The Folder Is ThereGrey Is The Copy Part Of The ScriptRed Is The Location Or Files As A VaribleThis Color Is The Folder Or File To Remove. Purple Is For Script NotesNotesIf You Want To Use One Varible For The EndSpot To DeleteThe Folder Then it Must Look Like ThisHow It Is In The ScriptDim EndSpot : EndSpot =("D:\TestCopy1FileType\")Re Edit Dim EndSpot : EndSpot =("D:\TestCopy1FileType")In The Script The Line Will Look Like thisEndSpot & "\"Also For Every If There Must Be A End IfTest The VBS ScriptDim Shell : Set Shell = CreateObject("Shell.Application")Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")Dim EndSpot : EndSpot =("D:\TestCopy1FileType\")Dim CopyFiletype2 : CopyFiletype2 =("C:\MyScripts\Scripts-Msfn-Uploads\*.exe")If Not FSO.FolderExists(EndSpot) ThenFso.CreateFolder(EndSpot)ElseIf FSO.FolderExists(EndSpot) ThenEnd IfEnd if set Folder = Shell.NameSpace(EndSpot) ' directory to copy to if not Folder is nothing Then Folder.CopyHere(CopyFiletype2) 'files or folder Z1 = MsgBox ("Would You Like To Keep The Test Folder" & vbCrLf & "Yes To keep" & Space(9) & "No To Delete", 4 + 64, "Copy And Delete template") If Z1 = Vbno Then F =FSO.deleteFolder("D:\TestCopy1FileType") Else If Z1 = VBYes Then MsgBox "Keeping The Test Folder", 0 + 32, "Keep The Test" end If end If end If Link to comment Share on other sites More sharing options...
Bold_Fortune Posted April 21, 2005 Author Share Posted April 21, 2005 Thanks, gunsmokingman. You put a lot of effort into that for me, and I appreciate it.Just now, a friend of mine at Jan's "Graphics an Stuff" had a splendid solution.Per Xrs2: "I would recommend just making the script move the files you want back (after it moves them all the first time)."So, I wrote this...and it works! (One happy camper here.)IF NOT EXIST "c:\backup\WINDOWS\inf" md c:\backup\WINDOWS\infMOVE c:\WINDOWS\inf\*.* c:\backup\WINDOWS\inf\IF NOT EXIST "c:\WINDOWS\inf" md c:\WINDOWS\infMOVE c:\backup\WINDOWS\inf\msports.inf c:\WINDOWS\inf\ Figured out this Code thing, un4given1. I first have to disable PopUpCop. (I can be really dumb a lot of the time.) Link to comment Share on other sites More sharing options...
Fredledingue Posted April 29, 2005 Share Posted April 29, 2005 BOld, try this VBS.set fso = createobject("scripting.filesystemobject")set folder = fso.getfolder("c:\WINDOWS\system32")For Each file in folder.filesFilename = file.name If fso.GetExtensionName(file.path)="ini" Then If Filename <> "fileiwanttokeep1.ini" And _ Filename <> "fileiwanttokeep2.ini" And _ Filename <> "fileiwanttokeep3.ini" And _ Filename <> "fileiwanttokeep4.ini" And _ Filename <> "fileiwanttokeep5.ini" And _ '----add as many as you want...---- Filename <> "fileiwanttokeep6.ini" Then Set f = fso.GetFile(file.path) f.move c:\backup\WINDOWS\inf End If End IfNextMsgBox "ok" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now