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
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
737 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
  • 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
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.

 
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 500 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

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

792 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