To many image files on my server

I have over 4000 images in each of several folders and only need about 2000 of them.  As we grow and add new products, the difference is going to get larger.  I fear the server will start to slow down when displaying the image files.  

Is there a windows program that would do a compare from an imported file list and either delete or move images not in the imported file list?

Thanks,

Mike
stroudtxAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Jose ParrotConnect With a Mentor Graphics ExpertCommented:
Hi,

Points of attention:
1. The moveme.txt should be in the current directory.
2. If DirectoryA or DirectoryB is a directory name with spaces, enclose it in quotation marks.
    For example,      C:\My Images Folder       type      "C:\My Images Folder"
   
Then run the command:

FOR /F %n in (moveme.txt) DO MOVE C:\DirectoryA\%n  C:\DirectoryB

Please note billmercer had posted correct instructions.

Jose
0
 
gugfuzCommented:
You could write a macro in vba that easily do the trick.
0
 
stroudtxAuthor Commented:
If I knew how to program in VBA. I do know asp vb, but I'm sure they are way different. I was hoping for an off the self solution.
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
gugfuzCommented:
OK, I will try something in ASP.
Does this imported file list contains the URL of the image files or the server path?
0
 
stroudtxAuthor Commented:
I can parse it out either way. I could even move just the files that are in the db and thus leave the old ones.
0
 
billmercerCommented:
>I could even move just the files that are in the db and thus leave the old ones.

A fairly simple batch file could do this job. Something like this:
   for /F %%I in (moveme.txt) do move %%I blah
where moveme.txt is a file listing the paths to the files you want to move, and blah is the folder to move 'em to.
There's a lot of power in the windows command prompt these days, it's much more flexible than it used to be.






0
 
stroudtxAuthor Commented:
interesting.  I've never run a batch file before and how would it know to go to the next line in the txt file.  Would they be seperated by lines, commas, tabs, etc?
0
 
billmercerCommented:
>I've never run a batch file before and how would it know to go to the next line in the txt file.
The ability to read lines from a file is built-in to the FOR command. The file names would be separated by returns (each file on its own line.) For example, moveme.txt might look like this:

F:\Documents\File001.txt
F:\Documents\File003.txt
F:\Documents\File005.txt
F:\Documents\File007.txt

With the command extensions available in Windows XP and 2000, you could even copy the directory structure from one drive to another.

You can read more about the FOR command and how to use it by typing HELP FOR at a command prompt.

0
 
stroudtxAuthor Commented:
I checked it out so somewhat understood.   I'm not a dos person so I don't know any commands nor the syntax.  Is there a web site or some reference point to go to?  
0
 
stroudtxAuthor Commented:
can anyone help me with the syntax here?

Mike
0
 
billmercerCommented:
Did you read the HELP FOR text? That gives a very concise explanation.
Go to a Windows command prompt. Type HELP FOR

Here's a reference for many common Windows batch commands, maybe it will be clearer.
  http://labmice.techtarget.com/articles/batchcmds.htm

>can anyone help me with the syntax here?
What exactly do you want to happen? If you give me a specific task you want to accomplish, I can help you create a batch file to do it. Do you want to move the old files to a different location?
Do you want to delete all the files on a list?
Do you have a list of files to be deleted, or a list of files to be kept?

General background...
The FOR command works like this:
  FOR %I  in (a set of files) DO some_command %I

This FOR command takes a file name or several file names contained in the parentheses.
It starts with the first file in that set, reads the name of that file into the variable %I, then does a command of some sort, which can contain the %I to make the command happen to a variable.
When the command has finished, it then get the next file, and does the command again.
It keeps getting the next file and doing the same command until it has gone through all the files in the list.

For example, if you have files A, B C, D, and E, you could enter this:
 FOR %I in (A B E) DO DEL %I

This will delete A, then B, then E, but will not affect C or D.

The set of files can be specified in several different ways. You can just type in a list of files, or you can use a wildcard, like this:
 FOR %I in (*.TMP) DO DEL %I
 
You can use the /R parameter to tell the FOR command to look not only in the current directory, but also any subdirectories.

FOR /F says that instead of typing in the names in the command, you want it to open up a text file and read the names from there. That's what the example I provided earlier does.

This:
   FOR /F %I in (FileNames.txt) DO COPY %I D:
will read each line from the file FileNames.txt, and COPY each file listed in that file to the D: drive.

%I is a variable. You can just type %I if you're typing the commands at the command prompt directly.
(You could use other letters besides I if you want, like %K, %Z, whtatever.)

In order to use these variables in a batch file, you have to double the percent symbols. So in a batch file, you need to put %%I, not just %I.

You don't HAVE to make a batch file, you can just type the command directly at the command prompt. It's convenient for testing, though.

To create a batch file, just open up NOTEPAD, and type in the commands, then save the file with a .BAT extension.

0
 
stroudtxAuthor Commented:
Thanks.

I created a text file called moveme.txt

files include:

thisimage.jpg
thisimage2.jpg
etc.

I want to move all that are in the moveme.txt file from

C:\DirectoryA

to

C:\DirectoryB

Mike
0
 
stroudtxAuthor Commented:
Looking forward to a solution here.  Thanks.  I think we are close.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.