?
Solved

To many image files on my server

Posted on 2006-06-19
13
Medium Priority
?
276 Views
Last Modified: 2010-04-06
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
0
Comment
Question by:stroudtx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 2
  • +1
13 Comments
 
LVL 3

Expert Comment

by:gugfuz
ID: 16942818
You could write a macro in vba that easily do the trick.
0
 

Author Comment

by:stroudtx
ID: 16942890
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
 
LVL 3

Expert Comment

by:gugfuz
ID: 16942991
OK, I will try something in ASP.
Does this imported file list contains the URL of the image files or the server path?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:stroudtx
ID: 16943050
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
 
LVL 19

Expert Comment

by:billmercer
ID: 16945239
>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
 

Author Comment

by:stroudtx
ID: 16945276
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
 
LVL 19

Expert Comment

by:billmercer
ID: 16947536
>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
 

Author Comment

by:stroudtx
ID: 16948620
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
 

Author Comment

by:stroudtx
ID: 16965908
can anyone help me with the syntax here?

Mike
0
 
LVL 19

Expert Comment

by:billmercer
ID: 16966165
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
 

Author Comment

by:stroudtx
ID: 16966271
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
 

Author Comment

by:stroudtx
ID: 16977354
Looking forward to a solution here.  Thanks.  I think we are close.
0
 
LVL 18

Accepted Solution

by:
Jose Parrot earned 1000 total points
ID: 17006929
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Keep your audience engaged and get the most out of your next presentation with these quick Prezi tips.
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
In addition to being a great web-based presentation tool, Prezi also makes it easy to save your presentation as a PDF to share with others as well. Learn how in this tutorial. Select the share icon from the top menu in your Prezi editor: Select "D…
Learn how to use the remote presentation tool in Prezi to allow you to harness the power of this cloud based presentation platform. You can show your presentation with a remote audience using this free tool.
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question