Solved

To many image files on my server

Posted on 2006-06-19
13
266 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
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 

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:
JoseParrot earned 250 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Not only does Prezi allow you to create non-linear presentations, it also makes it easy to apply transition animations between your frames. Learn how to apply a fade-in transition to select items and entire frames in this tutorial Select "Edit Path"…
Learn how to download your full Prezi presentation for offline presenting. Prezi doesn’t have to be viewed and shared in a web browser, even with a free account you can download your full presentation to share with others. Be sure to download any vi…

733 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