?
Solved

Script to scan the machines in the file and search for Mp3 and any song and movie files and move to a UNC location

Posted on 2007-12-05
19
Medium Priority
?
741 Views
Last Modified: 2010-04-24
Hi,

Script to scan the machines in the file and search for Mp3 and any song and movie files and move to a UNC location.
Without user interaction.The files copyed should be copyed to a folder by machine name as the foldername sepeartely.Is there a way to do this.
We have been asked to delete all such files but for a period of time we need to do it in such way.

Regards
Sharath
0
Comment
Question by:bsharath
[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
  • 10
  • 4
  • 3
  • +1
19 Comments
 
LVL 24

Expert Comment

by:fridom
ID: 20417719
Of course one can do it, any decent Shell can be used for it and any decent Scripting language includeing VBScript.
Just search recursivly through all the directories for files ending in .mp3 and then just copy it away.

Regards
Friedrich
0
 
LVL 11

Author Comment

by:bsharath
ID: 20417723
I need to cut and paste in the UNC path
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20418106
Try this as your starupscript Sharath...

Save this as bat file

C:
Cd\
Dir /s *.mp3 *.mpeg *.avi *.mpg > \\Server\Share\%computer%.txt

regards
Chandru
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 11

Author Comment

by:bsharath
ID: 20418222
Chandru can i do this only for a list of computers...
0
 
LVL 24

Expert Comment

by:fridom
ID: 20418539
Sorry, but there is no copying involved. It's just a listing of files.

Regards
Friedrich
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20418550
Do you have enough space to copy files and have it on both the places?
0
 
LVL 11

Author Comment

by:bsharath
ID: 20418564
Yes i have space and need to create the machine names as folder and then move them inside the created folders.Need to move them not copy
0
 
LVL 11

Author Comment

by:bsharath
ID: 20421362
I need to move all files not copy Chandru...
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20421409
But i think the initial post was about copying files
0
 
LVL 11

Author Comment

by:bsharath
ID: 20421438
No chandru my question was
Script to scan the machines in the file and search for Mp3 and any song and movie files and move to a UNC location

Move i meant cut > paste
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20421944
0
 
LVL 26

Accepted Solution

by:
farhankazi earned 2000 total points
ID: 20521301
Hi Sharath,
Try following batch script if this works for you!
The script move ALL .mp3, .avi, and .mpg file to specified network share

:: BATCH SCRIPT START 
@ECHO OFF
SETLOCAL EnableDelayedExpansion
SET NetShare=\\server\share
SET InputFile=Machines.txt
IF NOT EXIST "%NetShare%" ECHO Network share not found. &GOTO :EndScript
IF NOT EXIST "%InputFile%" ECHO "%InputFile%" file does not exist. &GOTO :EndScript
FOR %%R IN ("%InputFile%") DO IF %%~zR EQU 0 ECHO "%InputFile%" file is empty. &GOTO :EndScript
FOR /F %%c IN ('TYPE "%InputFile%"') DO (
	ECHO Processing: %%c
	IF NOT EXIST "!NetShare!\%%c" MD "!NetShare!\%%c"
	IF EXIST FileList.txt DEL /F /Q FileList.txt
	FOR /F "delims=: tokens=1" %%d IN ('WMIC /NODE:"%%c" LOGICALDISK WHERE "DriveType=3" GET Name ^|FIND ":"') DO (
		DIR \\%%c\%%d$\*.mp3 /S /B 2>NUL >>FileList.txt
		DIR \\%%c\%%d$\*.avi /S /B 2>NUL >>FileList.txt
		DIR \\%%c\%%d$\*.mpg /S /B 2>NUL >>FileList.txt)
	FOR /F "delims=*" %%f IN ('TYPE FileList.txt ^|FIND "\\"') DO MOVE /Y "%%f" "!NetShare!\%%c\" >NUL 2>&1
	MOVE FileList.txt "!NetShare!\%%c\" >NUL 2>&1)
 
:EndScript
ENDLOCAL
EXIT /B 0
:: BATCH SCRIPT END

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 20523553
Farhan does this move or just copy from the machines whose names are in the file.
Does it scan just c drive?
0
 
LVL 26

Expert Comment

by:farhankazi
ID: 20523591
>> Does this move or just copy from the machines whose names are in the file.
      Move
>> Does it scan just c drive?
      All fixed drives
0
 
LVL 11

Author Comment

by:bsharath
ID: 20523617
Farhan
The script creates a folder with the machinename and copies the file to the folder.I have the same file for a test in all the drives but it did not cut paste all just the file that i had in the desktop is moved.Can you add a way that if the file has duplicate copies it has to rename and move the file please.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20523624
There is a FileList.txt created in the folder with many paths what are those?
0
 
LVL 26

Expert Comment

by:farhankazi
ID: 20523666
FileList.txt file keeps record of original files location that are moved.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20523695
Farhan
The script creates a folder with the machinename and copies the file to the folder.I have the same file for a test in all the drives but it did not cut paste all just the file that i had in the desktop is moved.Can you add a way that if the file has duplicate copies it has to rename and move the file please.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20532371
Farhan a little more help ...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

770 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