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
734 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
Comment Utility
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
Comment Utility
I need to cut and paste in the UNC path
0
 
LVL 12

Expert Comment

by:chandru_sol
Comment Utility
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
 
LVL 11

Author Comment

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

Expert Comment

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

Regards
Friedrich
0
 
LVL 12

Expert Comment

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

Author Comment

by:bsharath
Comment Utility
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
Comment Utility
I need to move all files not copy Chandru...
0
 
LVL 12

Expert Comment

by:chandru_sol
Comment Utility
But i think the initial post was about copying files
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 11

Author Comment

by:bsharath
Comment Utility
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
Comment Utility
0
 
LVL 26

Accepted Solution

by:
farhankazi earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
>> 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
Comment Utility
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
Comment Utility
There is a FileList.txt created in the folder with many paths what are those?
0
 
LVL 26

Expert Comment

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

Author Comment

by:bsharath
Comment Utility
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
Comment Utility
Farhan a little more help ...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VBA open file from excel cell 4 33
Exit Loop after User Input 4 29
word0 challenge 3 56
Copy Files - Python 7 53
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

744 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now