Jump to content

using Switchblade just to search through a drive and copy custom selected files.


Carlyl3
 Share

Recommended Posts

I'm trying to setup Switchblade to search through the hard drive and copy only selected file of my choice... i.e.  logs*.zip

and then once completed, indicate that I can pull out the U3 USB flash drive.

I'm sure someone posted some code here that would do this, but I can't find it among all these posts.

help!

Link to comment
Share on other sites

  • 3 weeks later...

Well, I know how to do part of it from the command line.

@echo off
xcopy C:Documents and Settings%username%My Documentslogs*.zip /a /e /k 
exit

This will copy any thing called "logs(insert anything here).zip" from the My Documents folder into the directory launched from and close the command prompt when it is done. If I have done anything wrong, tell me please.

Link to comment
Share on other sites

@echo off
xcopy C:Documents and Settings%username%My Documentslogs*.zip /a /e /k 
exit

In order to go through different directories, you could use this line with the above code:

@echo off
REM say we only want to check the user's documents and settings path ...
cd %HOMEPATH%

FOR /F "tokens=*" %%i IN ('dir/s/b/x *.zip') DO xcopy /a /e /k /q "%%i" ..FILES

(of course, you would have to make a folder in your WIP folder called FILES for it to copy them into. Also, I found on my system when I tested this command that some of the zip files were quite big in size...)

Edit: I want to edit my above code, to let you know when it's done copying the files. Using a tool called MsgBox (found http://www.lgcoding.com.au/files/msgbox.exe ). The updated code is now:

]@echo off
REM say we only want to check the user's documents and settings path ...
cd %HOMEPATH%

FOR /F "tokens=*" %%i IN ('dir/s/b/x *.zip') DO xcopy /a /e /k /q "%%i" ..FILES
msgbox /BO /H /II /MS /T5 "Data Copied" Files have been copied successfully.

This will, when it has finished copying, display for 5 seconds a small dialog box, that says the data is copied OK. You can change the parameters in it (just type at a command prompt: msgbox /? )

msgbox_scrn.jpg

Link to comment
Share on other sites

I've a lil time, so I wrote a small tool 4 you.

FileCopier (fc.exe)

fc.exe "Drive:Searchstring" "Targetfolder" [/Include] [/Overwrite] [/Msgbox] [/Source]

"Drive:Searchstring"             Defines a Drive and a String which is searched for.
"Targetfolder"                        Defines a Targetfolder where the files will be copied to.
/Include                                 Includes Subfolders to the search.
/Overwrite                             Overwrites existing files
/Msgbox                                 Displays a Messagebox with the amount of copied files
/Source                                  Appends the Source of this program to a file

Example:
fc.exe "C:*.txt" "X:Files" /Include /Msgbox

Written in AHK

Changelog:

15.May.2K7   (17:40 GMT+1)

+ Fixed Bug (don't ignores allready existing files anymore)

+ Helpstrings (edited last @ Target)

+ Displays the amount of copied files and the amount of copied files in Megabytes

+ Notes added to the sourcecode

+ Increase speed of the program

Link to comment
Share on other sites

NP. I've modified my code again.

Changelog:

16.May.2K7 (15:37 GMT +1)

+ Added 2nd example to the Help

+ Added explanation of examples

+ Added "commandlinetool-beaviour" (if less than 2 parameters passed to the scipt, a cmd.exe window popps up shortly)

+ Bugfix: Recompile is now easier for developer who appended the source. (you don't have to rename the source now again)

+ Lil more explanation of the code into the source

+ Added credits

+ Sourcecode-Cleanup

Helpstrings:

fc.exe "Drive:Searchstring" "Targetfolder" [/Include] [/Overwrite] [/Msgbox] [/Source] [/?]

"Drive:Searchstring"     Defines a Drive and a String which is searched for.
"Targetfolder"            Defines a Targetfolder where the files will be copied to.
/Include                  Includes Subfolders to the search.
/Overwrite                Overwrites existing files
/Msgbox                   Displays a Messagebox with the amount of copied files
/Source                   Appends the Source of this program to a file
/?                        Displays this Help

Example:
fc.exe "C:*.txt" "X:Files" /Include /Msgbox
       Copies every textdocument of drive C: to folder X:Files and displays a Popup after finishing

fc.exe /Source
       Appends the Source of this tool to a .ahk File

UPDATED VERSION (Same link as above)

Link to comment
Share on other sites

Just a suggestion: Could you make it to where you could either do /src or /Source to append the source to an AHK file? Also, abbreviating the other options would be helpful, like /ow or of /Overwrite. It's just easier to type. This little utility is pretty neat. Keep up the good work!

Link to comment
Share on other sites

Shure, I could. But on the other hand with a wider range of parameters, the "compatibility" for errors increase.

but ok. I'll change the code to smaller stings. If you prefer to have a choose-range, simple change the sourcecode from eg:

If 1 = /Source

to

If 1 in /Source,/src,/s

to increase the parameterrange.

Updated Version

fc.exe "Drive:Searchstring" "Targetfolder" [/I] [/O] [/Box] 
fc.exe [/Src] [/?]

"Drive:Searchstring"       Defines a Drive and a String which is searched for.
"Targetfolder"              Defines a Targetfolder where the files will be copied to.
/I                          Includes Subfolders to the search.
/O                          Overwrites existing files
/Box                        Displays a Messagebox with the amount of copied files
/Src                        Appends the Source of this program to a file
/?                          Displays this Help

Example:
fc.exe "C:*.txt" "X:Files" /I /Box
       Copies every textdocument of drive C: to folder X:Files and displays a Popup after finishing

fc.exe /Src
       Appends the Source of this tool to a .ahk File

PS.: I update every time the version, so the link doesn't change, but the old version will be overwritten every time.

If someone want a special modification, PM me or send me a message over IM.

If it's possible for my scripting experience, i'll change it (but you have to be patient, I've sometimes to do a lot)

Link to comment
Share on other sites

  • 3 weeks later...

I think this code is great.  :-)

I was wondering, however, if it would be possible to make it more stealthy. My idea would be to copy the *.doc (or other types specified) files in My Documents folder on target machine to a temp folder on the harddrive, zip them and then email them out to an email (gmail) account like in kz26's suggestion, finally deleting the temp files so as to leave no trace. All done stealthily with no message or command window popups.

What do you think? It's basically a combination of your code with kz26's idea and the hacksaw capability to stealthily email out the results to a waiting gmail account.

Link to comment
Share on other sites

Ok

I have the fc. exe on the root of my usb.

Can you help me to run this file with the autorun. inf?

How can i run this file and copy all jpg from my documents folder without any visible window and at the end start browse the flash disk auto.

Thanks

Link to comment
Share on other sites

Hi!

@lixo: Yeah, It'd be no real problem to add this feature, but I've to add a Mailtool, a ziptool, ... and this wasn't the challenge. But feel free to modify the code if you want.

@ASTRAPI: If you execute a file via Autorun, only this file will be executed. The Explorer window won't open. Only if you work with another tool.

But I've coded a tool for this problem. (WARNING: This tool is in developement phase).

LAUNCH

So, first execute the tool with a doubleclick. This appends a autorun.inf file.

Write every item that shall be executed to the right selection. (Self explaining into the .inf file.)

Execute no. 1 : fc.exe "%Userprofile%*.jpg" ".Images" /o

Execute no. 2: explorer.exe .

Other paramerters of launch.exe:

/S       lauches every entry into the [Launch] Section
/V             (As second parameter) displays a pseudo "no-Virus" message at the end of launching

However, this tool is in developement status. I'll not be responsible for any damages.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...