Click to See Complete Forum and Search --> : Batch File rookie with an idea


Niclo Iste
June 24th, 2009, 07:44 AM
I don't know DOS enough to make the batch file I want to make. What I want to do is make a batch file that I can modify the variables on that can find, then copy, and then paste files to a new directory and a new drive. The reason I need to know the variables is because I want to be able to modify it for situations such as a client wanting me to find and move files for them and rather than do a search then copy and paste I'd prefer to just run a batch file so I can focus on other tasks. In addition to that I am sure I could modify the variables of what file/file type to find, and where to send it for things such as repairs also and probably other tasks when they arise. I already found one someone posted online on another site that details how to do a search and delete batch file but I don't know enough to edit this for my find, copy, and paste.

NooNoo
June 24th, 2009, 08:06 AM
Thing about dos batch files is that you have to work in 8.3

Now I assume you want to tell it to go look for all docs or pics or whatever and copy them to another drive? The question is, do you want to preserve the folder structure in which they are found?

You might be better off with robocopy... (http://en.wikipedia.org/wiki/Robocopy)

Niclo Iste
June 24th, 2009, 08:32 AM
At this point folder structure isn't really important. At the moment I just want to make something that can do a search, copy and paste. I intend to modify it to the needs of my virus removal and recovery of core system files when the system won't allow me to because of the infection stopping me and so on. I'm trying to remove myself of the need to plug their drive into a computer as much as possible to reduce time and costs with travel. And might attempt using such in remote assistance.

NooNoo
June 24th, 2009, 08:44 AM
how about you post some proposed searches?
Would you be searching for say all *.doc* on a machine?

Niclo Iste
June 24th, 2009, 08:50 AM
correct the search would be similar to this setup. I am using general file names just for sake of the explanation of what i want to do.

Find *.pst
Copy *found results* to g:\recovered data

The other setup I was going to do for replacements would have been

find *.pst
copy and replace *found results* to g:\recovered data

my biggest hurdle is not knowing the command for copying what was found in the search or even knowing the syntax to set that up.

NooNoo
June 24th, 2009, 11:18 AM
OK, well you need the for command...

for /r c:\ %X in (*.pst) do (copy %X D:\test\*.*)

If you want to put this in a batch file the %X must be written as %%X - the line above is for you to try out on a command line box - obviously you need to alter the drive letters to suit you.

Niclo Iste
June 24th, 2009, 02:48 PM
Cool thanks NooNoo I appreciate the input on that. As a side note my buddy showed me a command to use which I have yet to test for just find and copy which is "xcopy C:\*.pst /S D:\backup"

NooNoo
June 24th, 2009, 02:56 PM
careful with xcopy - the wrong version will have an interesting effect and it has a problem with long file/path names too.

Also ran your code,

And got

C:\Users\XXX>xcopy C:\*.pst /S D:\test\*.*
File not found - *.pst
0 File(s) copied

Which took a long time to come to that decision

Niclo Iste
June 24th, 2009, 02:58 PM
Ew well that's not cool. Thanks for the heads up on that I don't want a faulty tool to rely on.

NooNoo
June 25th, 2009, 02:34 AM
It's not faulty, it just has several versions....

CeeBee
June 25th, 2009, 10:35 AM
roocopy

NooNoo
June 25th, 2009, 10:41 AM
roocopy

Is that the jumped up version of robocopy? :D

CeeBee
June 25th, 2009, 11:47 AM
Is that the jumped up version of robocopy? :D
no, it's the typo version ;)

NooNoo
June 25th, 2009, 12:09 PM
roo... kangaroo....jumped.... get it? Nevermind....

Niclo Iste
June 25th, 2009, 01:02 PM
roo... kangaroo....jumped.... get it? Nevermind....

Perhaps if you had called it the "hopped up version" he'd have seen the pun. Also don't you have to install robocopy? I'd prefer not to have to install then uninstall software for this. Thanks for the suggestion though.

NooNoo
June 25th, 2009, 01:08 PM
Robocopy is part of Win7 and Vista...

Niclo Iste
June 25th, 2009, 03:50 PM
I never used it before and wasn't aware it was native to those OSes. Though it wouldn't help me on the majority xp machines I still service.

NooNoo
June 25th, 2009, 04:47 PM
True, but it won't be long before you are going to be seeing a lot of Win7 machines, so you may as well play with it.

Niclo Iste
June 25th, 2009, 05:22 PM
lol why must you always be right? I think I'm just a sucker for the old ways and that's why I'm so stubborn. Semi off topic but I'm trying to keep a collection of tools that would be handy in the command prompt and dos since I find they tend to be a more stable work around when infections and such arise. Sooner or later I'm going to attempt making a dos booting thumb drive just for fixing infections that way. Maybe I should start a thread asking how to do that. Or maybe there is something you can point me towards that might teach me neat dos commands and tricks. The biggest I'm interested in is how to utilize an active internet connection while in a dos environment to access and download updates or files I need.

NooNoo
June 25th, 2009, 06:13 PM
OK stop there.... you are confusing DOS (an operating system that had 7 major versions) and the command line available in the NT based OSes. Do not confuse the two... you will wind up in version hell.

Unless you are doing a lot of 98 or ME, forget DOS and look up recovery console. Learn command line and powershell.

Win7 gets sold for $50 for the next few weeks.... you are not going to get a lot of 98 and ME stuff....

Niclo Iste
June 25th, 2009, 06:23 PM
I never had much success with the recovery console allowing me to explore the directory trees and move files around. So I always figured it was a limited environment. That's why I'm looking into most of this. Generally I'd rather fix the system without having to load the GUI/windows. It always was much easier back in the win98 days to start in dos and fix windows files. I'm trying to recreate that and have some extra utilities for newer systems.

NooNoo
June 26th, 2009, 03:18 AM
Well you can go to safemode command line, but it still is not DOS!
Recovery console is limited - you can turn off services, copy or delete files, set attributes etc.

here is a list for command line commands (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true) As you can see, it does a lot more than DOS ever did... but it is just that - command line version of what you can do through the GUI.

El_Squid
October 14th, 2009, 12:17 PM
Gawds, I miss deltree! :sad:

Niclo Iste
October 14th, 2009, 12:21 PM
You and I both El_Squid!

By the way, thanks for replying to this I wasn't aware that NooNoo had put a link up for those commands.

CeeBee
October 14th, 2009, 02:28 PM
Gawds, I miss deltree! :sad:
rmdir [Drive:]Path [/s] [/q]

Matridom
October 15th, 2009, 07:56 AM
How about a linux Live CD or bootable USB stick with a *nix distro on it?

It will read NTFS, by-pass all permissions, and you can script commands fairly easy in the bash shell. Finally, since it's *nix, it will probably be immune to the virus on the system you are cleaning.

Niclo Iste
October 15th, 2009, 09:35 AM
How about a linux Live CD or bootable USB stick with a *nix distro on it?

It will read NTFS, by-pass all permissions, and you can script commands fairly easy in the bash shell. Finally, since it's *nix, it will probably be immune to the virus on the system you are cleaning.

Hmm it's plausible but I need dos or the command prompt to run the antispyware and andivirus tools I have.

Matridom
October 16th, 2009, 09:50 AM
Hmm it's plausible but I need dos or the command prompt to run the antispyware and andivirus tools I have.

I was making the assumption that if the system is so bad that you are resorting to a command shell to recover files, you would be re-formating the system.

Also as it's been stated earlier, there is no DOS in windows 2k and beyond. With XP/vista, I would say the majority of drives are formated NTFS, that means that your boot disks to dos won't be able to read the drive regardless to clean.

I find that if you can't clean it from inside of windows, the OS is too far gone to recover and you are re-installing.