FILEMONKEY FAQ
Copyright MonkeyJob Systems 2005
All rights reserved

Home FAQ Forums Contact
Download Tutorials FAQ Awards Report Bugs
 Search For Data
   

How can I copy files only if they contain specific text?



The following tutorial will demonstrate using the command line feature of FileMonkey to copy or move target files only if their contents contain specific text.

For example, you could use this feature to copy all target files that contain the text "toaster" in their bodies.

1.

Target your files in the main window. Click HERE for a targeting tutorial.

2.

Once you have targeted your files, select the "Quick-Find, Command Line" menu item from the main window.

3.

The Create/Run batch file window should now be open

make batch jobs

copy files contain

Load Script


4.

From the menu bar at the top of this window, select the "File / Load Code" menu item.

5.

This will open the load file dialogue box.

Use this box to navigate to the folder that FileMonkey is installed in (This is usually something like: C:\Program Files\FileMonk)

Select the file Copy Files That Contain.FM and click the "Load" button.



6.

Next, you need to enter the folder that you wish to copy all files to.

In the "Head" section, find the following line:

set DestDir="C:\_Backup"

create copy job


7.

We have entered the folder "C:\_Backup" as the default backup folder. You may want to change this to something else.

Delete the text "C:\_Backup" and enter the path that you wish to use here.

You MUST keep the encompassing quote marks otherwise this operation may not work.

For example: If you wish to use the path C:\My Documents then replace the line:

set DestDir="C:\_Backup"

with the line:

set DestDir="C:\My Documents"

8.

You must use a similar procedure to enter the search phrase. The search phrase cannot contain quote marks or carriage returns and must be less than 255 characters in length.

For example, if you want to use a search phrase of "toaster", find the following line in the "Head" code section:

set SerStr="hello"

and replace it with the line:

set SerStr="toaster"

9.

Next, you will need to specify the location of the FileMonkey dos find module. This module is provided with the FileMonkey installer. You will find it in the folder that FileMonkey is installed in. Typically, this will be:

C:\Program Files\FileMonk\DOSFIND.exe

You will need to check if this module is present. If you have installed FileMonkey in a different location then you need to edit the following line in the "File" code section:

start /w "" "c:\program files\filemonk\dosfind.exe" "<myDosFold><myDosFile>" %SerStr%

The above line should reflect the location of DOSFIND.exe. If you need to edit this line, make sure that you preserve the surrounding quote marks.


create copy job


10.

If you want to move files rather than copy them, find the following block of code (at the end of the file section):

:one
xcopy/H/K/Y <myDosFold><myDosFile> %DestDir%
goto next

and change it to:

:one
xcopy/H/K/Y <myDosFold><myDosFile> %DestDir%
attrib <myDosFold><myDosFile> -h
del <myDosFold><myDosFile>
goto next

Warning, there is no undo available for this feature. If unsure, please use the "Quick-Find, Copy" menu item from the FileMonkey main window to make a backup of your files first.

11.

To start the operation, select the "File/Compile And Run" menu item.
Related Topics:
FileMonkey Tutorials
Frequently Asked Questions
FoldMonkey - Create folders and or copy or move files.

  | About Us | Privacy Policy | Terms Of Use | Affiliates | Forums | Copyright ©2003 MonkeyJob Systems All Rights Reserved |