• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 745
  • Last Modified:

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

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
bsharath
Asked:
bsharath
  • 10
  • 4
  • 3
  • +1
1 Solution
 
fridomCommented:
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
 
bsharathAuthor Commented:
I need to cut and paste in the UNC path
0
 
chandru_solCommented:
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
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!

 
bsharathAuthor Commented:
Chandru can i do this only for a list of computers...
0
 
fridomCommented:
Sorry, but there is no copying involved. It's just a listing of files.

Regards
Friedrich
0
 
chandru_solCommented:
Do you have enough space to copy files and have it on both the places?
0
 
bsharathAuthor Commented:
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
 
bsharathAuthor Commented:
I need to move all files not copy Chandru...
0
 
chandru_solCommented:
But i think the initial post was about copying files
0
 
bsharathAuthor Commented:
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
 
chandru_solCommented:
0
 
Farhan KaziSystems EngineerCommented:
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
 
bsharathAuthor Commented:
Farhan does this move or just copy from the machines whose names are in the file.
Does it scan just c drive?
0
 
Farhan KaziSystems EngineerCommented:
>> 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
 
bsharathAuthor Commented:
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
 
bsharathAuthor Commented:
There is a FileList.txt created in the folder with many paths what are those?
0
 
Farhan KaziSystems EngineerCommented:
FileList.txt file keeps record of original files location that are moved.
0
 
bsharathAuthor Commented:
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
 
bsharathAuthor Commented:
Farhan a little more help ...
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 10
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now