Over 1 million tech questions and answers.

Batch File that grabs file names from folder to insert into batch file

Q: Batch File that grabs file names from folder to insert into batch file

Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can...

First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg.

Here's the code that I'm using:

ffmpeg -i folder\video.mp4 -f mp3 -ab 160000 -vn "\different folder\music.mp3"

what I would like to do is add to this so that I don't have to write out this code for every file I have... :/

I have the mp4 files in one folder and than the mp3 files are saving to another folder.

So here's an example of what the code will do if it isn't clear yet.

Folder 1:

video1.mp4
video2.mp4
video3.mp4

what it should do is grab video1.mp4 and convert it.

ffmpeg -i folder\video1.mp4 -f mp3 -ab 160000 -vn "\different folder\music1.mp3"

and than move onto the next one

ffmpeg -i folder\video2.mp4 -f mp3 -ab 160000 -vn "\different folder\music2.mp3"

and than the next one

ffmpeg -i folder\video3.mp4 -f mp3 -ab 160000 -vn "\different folder\music3.mp3"

It's going to have to grab the name from the mp4 file and insert it for the mp3 file.

I can get around pretty good in cmd if it's basic commands but when it comes to something like this I'm a little confused...

Thanks for the help in advance!
I'll see what i can do about searching some more on what I would have to do and if I find the solution I'll post it here if it isn't already answered.

RELEVANCY SCORE 200
Preferred Solution: Batch File that grabs file names from folder to insert into batch file

I recommend downloading and running Reimage. It's a computer repair tool that has been proven to identify and fix many Windows problems with a high level of success.

I've used it in the past to identify and fix everything from blue screens (BSOD's), ActiveX errors, corrupt files and processes, dll/exe/sys errors, recover lost memory, Windows update problems, defragging, malware removal etc.

You can download it direct from this link http://downloadreimage.com/download.php. (This link will automatically start a download of Reimage that you can save to your computer.)

A: Batch File that grabs file names from folder to insert into batch file

A DOS "for /f" loop should do the trick, although changing the filename extension for the output to do everything in one line escapes me at the moment.

Perhaps you could do a dir .\folder\*.mp4/s/b > mp4s.txt, then make a copy of that and edit each line to rename the file to the destination name, and save it as mp3s.txt. Then you just feed both the source (mp4s.txt) and destination (mp3s.txt) filesnames into the for /f loop which handles the ffmpeg conversion.

Quite a crude solution and you'd have to handpatch the destination filenames, but i can't think of how to get a source mp4 filename and then just change the extension.

Read other 3 answers
RELEVANCY SCORE 162

I am trying to write a batch program the list the current directory files that end in *.dwg
into a file on my C drive.
I have used the following code:
dir *.dwg /b >C:FileListing.txt
start notepad C:FileListing.txt

This code only gives file names in the current directory.
I need to have a list of path and file names in the file FileListing.txt
Is there a way to do that without including subdirectories??

Thank you,
 

A:Solved: Batch file to list file names in current Folder.

Read other 9 answers
RELEVANCY SCORE 140.8

Hi all,
I need help to create windows batch file for following requirements.
1. Remove .txt and .log file format in sub folders.
2. Zip individual file inside any sub folders and give file name through command prompt. 
3. Create sub folder zip file include file zip

Read other answers
RELEVANCY SCORE 140

Hi,
I have a question  that how to copy file from remote desktop user drive to my local machine using  xcopy or any other protocol.

This is my server path "\\Trail01" and here is the file location "c:\Users\ashique.sheikh\Desktop\Day2.R"
How can i give this is in my batch file. I have used this
net use "\\Trail01" "[email protected]" "/USER:ashique.sheikh"
XCOPY /Y \\Trail01\c:\users\ashique.sheikh\Desktop\Day2.R  "D:\VMI"
But its not working. It is give path error.
How can i download this or is there any other way to do it?

Read other answers
RELEVANCY SCORE 136

Dear All,

I need to create a batch file which can read the size of file(e.g. 1kb, 2kb...etc) from specific folder and detect 0kb file and convert it to text file (showing 0kb file size) with alarm.

I am not really sure how to write command for this batch file. Please help :-(
 

A:How to create a batch file to read size of file on specific folder path

Read other 10 answers
RELEVANCY SCORE 135.6

I have a computer that is a drone specifically for an outside LED sign. This computer is designed to never shut off and doesn't have any other program on it besides Operating System and the sign software. I need to create a batch file that I can place in the "start-up" folder that will open the program (LEDStudio10) and open the file that I want to play. I have already tried multiple attempts and I was hoping someone out there in sevenforums world would be able to point me in the right direction.

A:batch file open file for program in the startup folder

Task Scheduler. Create a new/basic task. You can invoke your batch script there. This can occur after boot completes, after user logon, etc. You can set it to run daily weekly hourly, etc. You can even have it delay X (preseleted time amounts) minutes/hours after boot/logon if you want.

Task Scheduler - Create New Task

Read other 1 answers
RELEVANCY SCORE 135.6

I want a batch to select and open a random link file in a folder i have. All the links are music videos I like to listen to, and I kind of want to just have an option for 'surprise me!'.
I can change the file names if I have to, and I have a basic batch file ability. I know the simple commands, but nothing of the variables, signs-involving commands (&%!?), etc.

Also, I want to learn a whole lot more about programming/java/batch file, so it'd be awesome if any code could be explained. Thank you, in advance

A:I need a batch file to open a random file within a certain folder/path

There's a free Windows scripting language called Autoit3 that would do this task easily using these functons:

Random
_FileListToArray

AutoIt - AutoItScript
It has a Basic like syntax and is easy to learn.

Another popular scripting for Windows is AutoHotkey
AutoHotkey: macro and automation Windows scripting language

The syntax can be confusing but it has object support and is more powerful.

Of course there are tons of others for Windows:
Rexx
Python
Perl
Ruby

Here's a list. The details for each tell which OS are supported:
Free Programming Languages - Freebyte's Guide to

Read other 5 answers
RELEVANCY SCORE 133.6

Hello all , i am new to batch programming.

I wish to have a batch file to read .apk file from folder and then copy it to another folder. Then it should rename the copied apk file to test.apk

eg:
i have a file in folder e:\apps\angrybirds.apk , I want to copy this angrybirds.apk to d:\apps and rename it to test.apk

Here the file names in the e:\apps\ will be changing. So what ever may be the name , it should read the name of the file from e:\apps\ folder , copy it to d:\apps\ and rename it to "test.apk" . Test.apk is a fixed rename
 

A:Solved: Batch file to copy a file from folder and rename it in another folder

Read other 12 answers
RELEVANCY SCORE 129.2

Hi,
I have recently been in the process of encrypting some sensitive information on my external hard drive, and I would like to go one more step in securing my data.

So far, I have encrypted the hard drive using "TrueCrypt", so the hard drive is only accessable by entering a a 16 digit password.

I now want to randomize the names of each file in the hard drive.

I need a batch file that can do this for me.
It should go through any subfolders in the hard drive, and randomize the name of each file (excluding the extension)

Anyone know how to do this?
 

A:Batch File to randomize names of all files in a partition

Read other 6 answers
RELEVANCY SCORE 127.6

Hello.

I need a batch script that reads 2 file names from folder "A" and then checks if they are located in folder "B". And if they are present in folder "B" then they needs to be deleted from folder "B".

How is the best way to do that ?

Any help i greatly appreciated

Ketasmurf
 

A:Batch help: Get file names and check if exict in diferent folders

How do we determine what the 2 files are? Are these 2 files the only files in Folder A? Are they always the same file name?
This is a rather easy batch file once we know that.
 

Read other 3 answers
RELEVANCY SCORE 127.2

I'm trying to write a .bat that's supposed to handle the very simple task of copying a file to the desktop.

Something like:

copy x:\folder\file.ext [desktop]\file_backup.ext

The problem: [desktop].

It would be really easy if I could simply insert %desktop% the same way as %windir% etc. Unfortunately, %desktop% doesn't exist.

Using the variable for userprofile doesn't work either, because the user may have moved the desktop folder out of the docs & sets folder to any other location, and not necessarily on the same partition or drive.

It would be easy in a .vbs, but that won't work if the windows script host is locked down or disabled.

So it has to be a batch file. Does anyone know how to explain a .bat how to find the desktop?
 

A:Batch file: how to insert desktop location into copy command

Read other 16 answers
RELEVANCY SCORE 124.8

Hi all,

Any idea how to write Batch File .bat to copy file from File Sharing & FTP Hosting to local directory.

Current the File Sharing & FTP Hosting is SMARTFILE.

I don't want to use WINSCP as the connector.

Thanks

A:Batch File .bat to copy file from File Sharing & FTP Hosting

Hi Chacha,

Give this batch file a try. All text in red, you should adjust before running.


Code:
@echo off
(
echo.Username
echo.Password
echo.lcd C:\Some\local\directory
echo.cd /Some/server/path
echo.binary
echo.get Some_file_to_download.txt
echo.bye
) > "%TEMP%\_%~n0.ftp"
ftp -s:"%TEMP%\_%~n0.ftp" "12.34.56.78"
del "%TEMP%\_%~n0.ftp"

Read other 1 answers
RELEVANCY SCORE 124

If someone can Please help, I just need the Data in the XML tag extracted to Batch File Variable....the rest i figured out and works great for the backup...just need the extracted tags...
thank you

i have a parent directory that contains a sub directory and a XML file that i need a batch to read 2 specific tags then create a Set command in the batch with those 2 lines to create a backup folder with the tags as the names and such. looks like this:

Parent Directory = XML
XML Folder contains > WJFKB02229001.D Folder & Config.xml File

I need to read the contents of the xml "Config.xml" extract the PhaseID Tag data "WJFKB02229001"
Also need to extract the BoxID "D", I don't need anything else on these seperate lines.

keep trying the following For /F command but no luck
Code:
[COLOR=red]for /f "tokens=1 delims=[" %%G in ("PHASEID" %path%\%myfile%) DO ([/COLOR]
[COLOR=red]set PhaseID=%%G[/COLOR]
[COLOR=red])[/COLOR]
[COLOR=red]echo Phase: %PhaseID%[/COLOR]
pause

and i've searched so many sites and forums with no real help on this one....the data is contained in the xml, weird enough i guess that it's enclosed in brackets "[", which all the forums i read and try it either replies with a blank variable being passed or says it can't find the file at all....

PLEASE HELP, lol

Code:

:StartSet
Set PhaseID="[COLOR=red][B][I]Extracted PhaseID from xml[/I][/B][/COLOR]"
Set BoxID="... Read more

A:Solved: Batch File Extract TAGID to Batch Variable? weird

Read other 16 answers
RELEVANCY SCORE 121.6

I have a program called defprint on C:\

I want to create a batch file that I can put in the All Users startup folder to run the defprint program when any user logs in.

What is the coding in the batch file to go with this line so that it will automatically run the program in the background.

C:\defprint /d IP_10.11.9.2

Thanks

Paul
 

A:batch file in startup folder

I think all you need to do is create a shortcut to the program. On the shortcut > Properties > Target line, you can add the switch:

/d IP_10.11.9.2

after
C:\defprint

so that it reads:

C:\defprint /d IP_10.11.9.2

Put the modified shortcut in the All Users Startup folder.

Anyway, this question probably would be answered best in the "Development" forum where the experienced coders are more likely to be found.
 

Read other 3 answers
RELEVANCY SCORE 121.6

Hi all, i am trying to get a simple batch file to find the path to a certain file, which may vary, but the file name remains the same inside different folders.. would this be possible using batch or would there be a way to do it using a different method?

Also would it be possible to take the path to this file and set it as a variable for use in a DIFFERENT batch file, i have setx in system32 to set a new environment variable if i can get the filepath to be set from there..

anyone needs any more information please ask but any help would be appreciated.
 

A:Search for file/folder using batch

Probably need to full description of what you want to do - maybe a batch file is not the best answer.

For simple example, you could try a batch file containing the command

DIR C:\%1 /s > pathout.txt

Then %1 is a variable, so you would use the batch file as : findfile name_of_a_file where you substitue the name of the file you are searching for each time you use the batch file. The DIR command lists all the files of that name (and wild card could be used just as easily), with the /S switch causing a recursive search through subdirectories, starting at C:\ The redirection parameter causes the ourput of the DIR command to be output to a text file called pathout.txt.

If you examine pathout.txt it contains a set of paths and files found in the format

Directory of C:\mydocu~1\personal

PERSONAL.DOC 36234 28/07/2008 10:59

where (because this is a surviving Dos program), the pathname is stated in the old Dos 8.3 layout. You see what I mean by 'not the best answer' ? Then the path(s) could be extracted by, for example, a simple basic program which in turn could actually build, or create the actual paths for use in a different batch file.

There are umpteen freeware programs from the days of yore capable of doing the same thing as DIR in a million different ways, but sticking to just Windows XP, the Dir command works as described, the ATTRIB command (found in c:\windows\system32) can do much the same thing but outputs full path names without s... Read more

Read other 2 answers
RELEVANCY SCORE 121.6

I would like to create a batch file to delete a specific folder. The folder is PGP Corporation. When I try to execute del PGP Corportion it is really trying to delete a folder called PGP. It isn't seeing that PGP Corportation is the entire file name because of the space. Do you know what I need? Thanks for your help!

A:Batch file to delete folder

Values with embedded spaces need to be quoted. Also, you can't just use the del or erase command for directories. You need to use the rmdir (remove directory) command.

Like this:

rmdir /s /q "C:\PGP Corporation"

Read other 8 answers
RELEVANCY SCORE 121.6

Hi, I'm wondering,
is there a way I can encrypt a folder with a batch file,
then decrypt it using a password only I know?
or is there another command line tool that would allow me to do this?
 

Read other answers
RELEVANCY SCORE 120.8

I would like to know if there is a way to open a file in a program. Basically I want something like this (this is totally wrong):

open "C:Users\*My name*\My Documents\run.swf" in "C:\Program Files (x86)\Mozilla Firefox\firefox.exe

Thanks
 

A:Create a batch file to open a certain file in a certain file

The more standard way to do that is to use the start cmd. You call the program first and the file name second.

start "" "c:\windows\notepad.exe" "c:\somepath\logfile.txt"
 

Read other 2 answers
RELEVANCY SCORE 120.4

hello, is it possible to have a batch file make a shared folder?
 

A:batch file make a shared folder?

Welcome to TSG!

Shared as in Shared on the network, or just shared with other users on the same PC?
Both are possible.
MD - Make Directory
Cacls - set NTFS permissions
Net Share - create network share

For more info, type these commands:
MD /?
Cacls /?
Net Share /?
 

Read other 2 answers
RELEVANCY SCORE 120.4

Ok, so I know i was pretty stupid to run it, but it didn't look so bad, especially since it was possible to abort the command anyway.

Here's the code:


So basically, this code's supposed to give me 13 seconds before I shutdown my computer. Now, the code to abort it is "shutdown -a", which I did, but now I can't get into the Start Menu folder under All Users. I'm pretty sure my computer will try to shutdown again when I restart, since it's in my startup, so how can I get rid of this?

Edit:
Btw, I forgot to mention that not only does it freeze up, it seems to redirect me to some microsoft software protection link

Edit again:
So I booted up CCleaner and it seems like it didn't get copied into my startup? I had run a batch file before that was called "himao" (which was in the startup and so I deleted it), so I'm not sure if I need to post a hijackthis log or anything for anyone to confirm if this batch only did try to shutdown my computer.

A:After Running Batch File, I Can't Get Into The Folder Where It's Located!

I removed the batch file from your post so others do not inadvertently try to play with it.

All that batch file did was copy itself to the all users startup programs folder, hide itself, shutdown your computer, display the message "CRITICAL COMPUTING ERROR!
Just kidding it's a virus.", and then start clock.avi which is on all Windows XP installs (maybe other versions).

Is this what happened on your computer? If not, and if you cant find the file in your all users startup folder, then its probably something else that is causing a problem on your machine. Do you have all the windows updates?

Read other 3 answers
RELEVANCY SCORE 120.4

Hello,

I am kind of new to this batch scripting and was wondering how one could check the existence of a file or folder in a batch program. I am using XP.
Any help or suggesstions is greatly appreciated. Thanks.

Jerardfjay :-)

A:check existence of file or folder in batch

Hi Jerardfjay and welcome to TSF!

If you're making a dos style batch file, the info you're looking for should be this:


Code:
IF [NOT] EXIST filename command ELSE command
EG:


Code:
IF EXIST hello.txt (
DEL hello.txt
) ELSE (
ECHO hello.txt is missing
)
the 'NOT' is optional, as is the 'ELSE' section

More information can be found by typing HELP IF at the command prompt.

Read other 7 answers
RELEVANCY SCORE 120.4

Hi, I don't know if I am posting this in the right place but here is my problem:

I want to create a batch file that will load all the video files in a folder without opening them. I think this is possible and other people have done it for image files from what I've read online (loading the icons in a folder). I can scroll through and load each file individually but takes too long to do each time. If someone is familiar with righting batch scrypt then I would think how to do this would have a simple answer. I tried something suggested in another forum on a different website but it didn't work. They had the command:

@echo off
explorer C:\FolderName\SubfolderName
exit

This opened the folder location but didn't load all of content. I would still have to manually scroll through and load everything.

If Someone knows how to do this and can tell me exactly what to type in (what command/scrypt) for the batch file that would be perfect!

Thanks

Read other answers
RELEVANCY SCORE 120.4

Hi all,

I need to execute the Windows command:

metaflac --dont-use-padding --remove --block-type="PADDING" Filename.flac

For every file in a folder, including every file in the subfolders! (Two levels of subfolders.) The file name extension is as mentioned above .flac.

I understand a batch file is the best way to accomplish this, but what should it contain?

Many thanks!
 

A:How do I write a batch file for all files in a folder?

Read other 6 answers
RELEVANCY SCORE 120.4

I'm trying to write a batch file that when run creates a folder named "Backup" followed by the time it was created, and then copies files to that folder.

When I run

md "C:\Users\MasterControlProgram\Documents\MC Server With Backup\Backups\Backup %DATE%\"
xcopy /e /v /y "C:\Users\MasterControlProgram\Documents\MC Server With Backup\Server\world" "C:\Users\MasterControlProgram\Documents\MC Server With Backup\Backups\Backup %DATE%\"
pause

It creates a folder named the date it was created and places the folders in it. How do I make it so the folder is named the time instead of the date?

A:Batch file to create a folder with name of the time.

you could do something like the below.
*disclaimer*: I am a fairly decent UNIX shell script programmer, but I suck at Windows programming. I did NOT test this out, but it should give you the general idea.

set SOURCEFOLDER="C:\Master"
set BACKUPTIME=%TIME%
set BACKUPFOLDER="C:\blah\Backup %BACKUPTIME%"

md "%BACKUPFOLDER%"
xcopy foo "%SOURCEFOLDER%" "%BACKUPFOLDER%"

Read other 2 answers
RELEVANCY SCORE 120.4

I have a folder on a network drive that I would like to copy to another location on another network drive. The source folder should copy over the destination folder, part of the path to the destination folder to be copied over changes based on the person who signs into the PC; OS is XP. This is what I thought would work but hasn?t. Any help would be much appreciated.

XCOPY ?\\Server Name\ Folder1\Folder to be copied? ?\\Server Name\%userprofile%\Folder\my documents\Same Folder Name As in The source folder to be copied over" /E /C /R /I /K /Y

A:Copy Folder batch File Issue

XCOPY ?\\Server Name\Folder1\SourceFolder? ?\\Server Name\%username%\Folder\my documents\DestinationFolder" /E /C /R /I /K /Y

Hope this helps

Read other 1 answers
RELEVANCY SCORE 120.4

Hi, I don't know if I am posting this in the right place but here is my problem:

I want to create a batch file that will load all the video files in a folder without opening them. I think this is possible and other people have done it for image files from what I've read online (loading the icons in a folder). I can scroll through and load each file individually but takes too long to do each time. If someone is familiar with righting batch scrypt then I would think how to do this would have a simple answer. I tried something suggested in another forum on a different website but it didn't work. They had the command:

@echo off
explorer C:\FolderName\SubfolderName
exit

This opened the folder location but didn't load all of content. I would still have to manually scroll through and load everything.

If Someone knows how to do this and can tell me exactly what to type in (what command/scrypt) for the batch file that would be perfect!

Thanks

A:Batch File to Load Icons in Folder

Hmm.. Where are you trying to load them ?

If you're talking about loading video files to a player, most players have an option of a Media library/playlist, just point it to the folder and the app will auto scan and load all the video files in a given folder.

Read other 4 answers
RELEVANCY SCORE 120.4

Hi,

I found an usefull batch on this thread:

http://forums.techguy.org/all-other-software/697666-winrar-command-line-separate-archives.html

My problem is that it only works with files, it doesn t take in account sub-folders.

I would need the batch to archive each files and first subfolder encountered in separate archive on the given folder (that's what the gui usually do when you do it manually).

Thanks for you help!
 

Read other answers
RELEVANCY SCORE 120.4

So here is my problem, once I download a file I run this script:

filebot -script fn:amc --output "E:/Completed" --log-file amc.log --action copy --conflict override -non-strict --def subtitles=en artwork=y "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D"

After this script has ran, it retrieves information, renames the file and moves this file/s to a folder. However, it leaves the initial folder/file (The original) behind, instead of being deleted. I'ts quite frustrating... since I did not know how to tweak the script to do that, I figured I needed to use a batch file to remove the original folder, however the batch file I have written only deletes files not folders. So, when the batch file runs (Automatically everyday via Task Scheduler) it asks (Are you sure? Y/N?)

Is there a way I can tweak the original script to delete this original folder/file that had been downloaded after it has done it's thing? If not, is there any way to remove the folder via the batch file I wrote?

This is the batch file:
forfiles -p "E:\Completed" -s -m *.* /D -0 /C "cmd /c del @path"

Any help would be greatly appreciated. Thank you.

Read other answers
RELEVANCY SCORE 120.4

The batch file I am creating needs a command to create a temporary folder and then delete it when no longer needed. can this be done? How?
 
Bill

A:How to create a folder in a batch file,( .bat) and delete it

 Just use the mkdir command.  For the syntax just type mkdir /? from the command prompt.
 
Good luck.

Read other 3 answers
RELEVANCY SCORE 120.4

Hi

I have a batch file which should delete everything under specified folder. the batch file ask the user to specified the folder which then be stored against %vmpath% variable. The following script is deleting every thing including the specified folder but i do not want to delete the specified folder. Sorry i am very new to batch scripting, require some help please.

IF Exist "%vmpath%\EMS96.exe" RD /S "%vmpath%\*"

thank you
 

A:Delete Folder Content with Batch file

Easiest to just recreate the folder after deleting it:

Code:
If Exist "%vmpath%" RD /S /Q "%vmpath%"
MD "%vmpath%
You don't need to specify a file name, unless you only want to delete the tree if that file exists.

If the parent folder can't be deleted and then recreated, you need a For loop to get the subfolder names.

Code:
PushD "%vmpath%"
Del /Q /F *.*
For /F "Tokens=1 Delims=" %%I In ('Dir /AD /B') Do RD /Q /S "%%I"
PopD

I've added a bit more in the following. This first switches to the folder specified on line 2, so the path entered must be relative to that folder. This is to prevent someone from typing C:\Windows and deleting the entire Windows tree. Do Not use C:\, or they can type Windows and delete the Windows tree.
If this will be used by multiple users, and the folders to be deleted are in there profile, you can use the %Userprofile% variable so it will be specific to the current user.

Code:
@Echo Off
PushD C:\Test Dir1
:_Ask
Set /P vmpath=Please enter the Parent Folder name relative to %CD%:
If /I "%vmpath%"=="exit" PopD&Goto :EOF
If NOT EXIST "%CD%\%vmpath%" Echo Unable to locate "%CD%\%vmpath%". Please check spelling.&Goto _Ask
:_YN
Echo All Files and folders contained in %CD%\%vmpath% Will be Deleted!
Set /P _Confirm=Are you sure? (Y/N):
If /I "%_Confirm%"=="N" Goto :_Ask
If /I NOT "%_Confirm%"=="Y" E... Read more

Read other 2 answers
RELEVANCY SCORE 120.4

I have a few LNK files in the same folder and would like to write a batch file that opens all of these links without explicitly having each link listed in the batch file. Is there a way to open all links in one folder? I would presume so, considering Windows has for the most part always had a Startup folder, but I'm not interested in using the Startup folder. I would like these items to open only if I access this batch file.

Is there a way to do this?

A:Batch File to Open ALL Links in Folder

@joshskorn

Here is a VBScript that will do what you want. It has no error checking it will just run everything in the C:\Program Files\Links folder.




Code:

Set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService. _
ExecQuery("Select * from CIM_DataFile where Path = '\\Program Files\\Links\\'")
For Each objFile in colFiles
WshShell.Run Chr(34) & objFile.Name & Chr(34)
Next

Read other 4 answers
RELEVANCY SCORE 120.4

Hello,
Wanted to see if any one here wouldn't mind writing a batch file or script that would move multiple files to a target folder. Here are the specifics:
HDD1 Contains Folders A,B,C,etc...
Folder A contains Folder A1 which contains File A2
Folder B contains Folder B1 which contains File B2
Folder C contains Folder C1 which contains File C2
Folder D contains Folder D1 which contains File D2
Folder E contains Folder E1 which contains File E2
Folder F contains Folder F1 which contains File F2

And what I need to do is move A2,B2,...F2.. to the drive root.

This would really save some time over moving these files manually, because they're numerous.
Or if you know of any utilities that can do this, please let me know
Thanks.

A:Batch file for moving files to folder?

I am assuming that these all folders are in X drive

such that your file A2.xxx is in X:\Folder A\Folder A1






Quote:
move "X:\Folder A\Folder A1\File A2.xxx" X:\
move "X:\Folder B\Folder B1\File B2.xxx" X:\
move "X:\Folder C\Folder C1\File C2.xxx" X:\
move "X:\Folder D\Folder D1\File D2.xxx" X:\
move "X:\Folder E\Folder E1\File E2.xxx" X:\
move "X:\Folder F\Folder F1\File F2.xxx" X:\


save it as bat file.
If you are using windows 7 than open the file in Administrator mode.

I hope it will help

Read other 9 answers
RELEVANCY SCORE 120.4

Hello
I have been trying to create a shortcut to launch a batch file one folder up from the shortcut location.
I have been able to do this using and intermediate batch file in the same folder as the shortcut as follows:
Intermediate.bat:
@echo off
FOR %%V IN ("%~dp0..\") DO set curdrv=%%~dpV
start "" %curdrv%Oneup.bat

And the shortcut target is:
%windir%\system32\cmd.exe /c Intermediate.bat

and the 'Start in' is left blank.

This way I can move these folders anywhere on the drive or another drive and the shortcut still works.
However, I would like to leave out the Intermediate.bat file and launch the Oneup.bat directly. I tried:
%windir%\system32\cmd.exe /c FOR %%V IN ("%~dp0..\") DO set curdrv=%%~dpV && start "" %curdrv%Oneup.bat
in the Target of the shortcut, but it doesn't work.
Is there some trick to getting this to work?
Thanks

Read other answers
RELEVANCY SCORE 120.4

Hello Guys,

I need to create a batch file which renames a folder from one name to a date in the format of YYYYMMDD. I see where you can do it on a file but for the life of me I can't find out how to do it for a folder using the REN command. Any suggestions would be helpful.

Thanks in advance...
 

A:Batch File Help (Renaming a folder to a date)

AFAIK ren works the same on folders as on files. have you tried it?
 

Read other 1 answers
RELEVANCY SCORE 120

Hiya,

I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups.

Two questions:
1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd rather keep a standard 'workflow' for other users who use the machine.

2. I'm 'ok' with batch files, but i've never tried to mirror to a different folder each time (automagically). What i'd like to do is have it backup a folder and call it "blah.1" then "blah.2" each time it is run, and then repeat once it gets to "blah.9" so it doesn't keep growing forever. I don't know how to do this.

I realise no.2 is not really for this forum, but someone might know and i might as well ask

Thanks.

A:How to run a batch file at logoff & some batch scripting help please

I found an answer to the logoff/shutdown:
How to schedule a task to run when shutting down windows - Stack Overflow

And the batch file folders:
robocopy - Insert current date in to destination folder structure - Stack Overflow

Read other 1 answers
RELEVANCY SCORE 119.2

hello, I was wondering just a few seconds why the subject Batch file to delete folder had been closed? the problem hasn't been solved?

So I was also wondering how to delete subfolders in batch command line or file?

A:[SOLVED] Batch file or command to delete folder

Oh! how stupid am I.

few minutes in google and the answer is :
for example you are dealing with the C:\temp folder and you want to erase all elements in it!
batch file :
@echo off

del "C:\temp\*" /Q /F /S
for /d %%X in ("C:\temp\*") do RMDIR /S /Q %%X

exit

command line for delete subfolders (if you want to test) :
for /d %X in ("C:\temp\*") do RMDIR /S /Q %X

I think it's larger better than erase the "C:\temp" folder and recreate it! Because if you want to do this for all the temporary folders (windows has it tricks)... it will be long. fortunately, you wouldn't do that because I made it for you, enjoy (just replace %profile% by you'r profile name or the profile name variable (%USERNAME%)):
@echo off
del "C:\Documents and Settings\%profile%\Local Settings\Temp\*" /Q /F /S
for /d %%X in ("C:\Documents and Settings\%profile%\Local Settings\Temp\*") do RMDIR /S /Q %%X

del "C:\Documents and Settings\%profile%\Local Settings\Temporary Internet Files\Content.IE5\*" /Q /F /S
for /d %%X in ("C:\Documents and Settings\%profile%\Local Settings\Temporary Internet Files\Content.IE5\*") do RMDIR /S /Q %%X

del "C:\Documents and Settings\%profile%\Local Settings\Application Data\Temp\*" /Q /F /S
for /d %%X in ("C:\Documents and Settings\%profile%\Local Settings\Application Data\Temp\*") do RMDIR /S /Q %%X

del "C:\temp\*" /Q /F /S
for /d %%X in ("C:\temp\*") do RM... Read more

Read other 2 answers
RELEVANCY SCORE 119.2

Does anyone know of a way to do this...

I have a bunch of files under a main folder... call it.. "FolderX".. under folderX are sub folders.. say... "Folder1" "Folder2" etc.. under those folders are "Folder1B" "Folder1C" etc...

I want to move files out of those subfolders and into the root of folderX..

I'm guessing a vbs script could be written but i'm not sure on this?

Anyone have any examples of how to do this?

Thanks

Read other answers
RELEVANCY SCORE 119.2

I need help with a batch file to copy the contents of my source dir to the destination dir that is to be created with that days date using xcopy or robocopy. Any help is appreciated!

A:Need a Batch File to Copy to a Custom Dest Folder

This should get you started...

for /F "tokens=1-4 delims=/- " %%A in ('date/T') do set DATE=%%A-%%B-%%C
md c:\tmp\%DATE%
xcopy c:\output c:\tmp\%DATE% /s

Read other 4 answers
RELEVANCY SCORE 119.2

Hope I can explain my difficulty.
I have duplicated folders album name for all my music files.
As there is quite a considerable number I wondered if it was possible to batch file (automate) the process.

I can not delete "d" as this would delete all the tracks.
What I need to do is move the tracks at "e" into folder "c" and delete the then empty folder "d"
Folder structure is thus:

(a) Music Collection
(b) /Artist Name
(c) /Artist Name/Album Name
/Artist Name/Album Name/Album Name
(e) /Artist Name/Album Name/Album Name/The Tracks

What I am trying to end up with is:
/Artist Name
/Album Name
/The Track files

Is this possible or has anyone any suggestions.
Thanks for looking

A:Batch file to move (many) duplicted folder contents - Help!!

You can try this;

DropIt: Sort Your Files With A Drop!

<http://dropit.sourceforge.net/>

You can set up rules so that the software sorts your files as you want them.

There are lots of utilities for checking duplicates;

AllDup, from this site, is a good one;

AllSync Backup Software: windows backup, backup and restore, backup program, sync program, pc backup software, backup utility, backup solution, computer backup, sync folders, automatic backup, file synchronization

<http://www.allsync.biz/en_index.htm>

All these things have to be used with due care.

Regards....Mike Connor

Read other 3 answers
RELEVANCY SCORE 119.2

Hi

I am using following batch file for cleaning the desktop and also for taking backup of desktop:

@echo off

set curr_date=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%

mkdir "%USERPROFILE%\My Documents\backup\%curr_date%_backup"

xcopy "%USERPROFILE%\Desktop" "%USERPROFILE%\My Documents\backup\%curr_date%_backup" /D/S/H/V/C/F/K/Y

for /d /r "%USERPROFILE%\Desktop" %%x in (*) do rd /s /q "%%x"
for /r "%USERPROFILE%\Desktop" %%x in (*) do del /f "%%x"

copy "%USERPROFILE%\My Documents\backup\%curr_date%_backup\*.lnk" "%USERPROFILE%\Desktop\"

del /q "%USERPROFILE%\My Documents\backup\%curr_date%_backup\*.lnk"

In the first line I am creating a folder with current date, e.g. curr_date_backup. Second, copying the contents of Desktop to the newly created folder. Third, deleting directories from the desktop. Forth, deleting files from the desktop. fifth, Copy back all the shortcuts to the desktop. sixth, deleting all the shortcuts from Current date folder.

This batch file is working perfectly in Windows XP. It works in win 7 also but the problem is that the name of the current date folder created by first command is "Desktop". when I use command prompt to check the name, the name is correct. I checked the properties of the folder the correct is there also. But in windows the name doesn't match with the expected one.

I need help. Kindly tell me what's going on? why window 7... Read more

A:How to create a current date folder using batch file?

Works for me, at least the first two commands work as advertised.

test.bat
set curr_date=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%
echo %curr_date%"

mkdir "%USERPROFILE%\My Documents\backup\%curr_date%_backup"
dir "%USERPROFILE%\My Documents\backup"






Quote:
C:\Users\xxxxxxx>set curr_date=2011-11-21

C:\Users\xxxxxxx>echo 2011-11-21"
2011-11-21"

C:\Users\xxxxxxx>mkdir "C:\Users\xxxxxxx\My Documents\backup\2011-11-21_backup"

C:\Users\xxxxxxx>dir "C:\Users\xxxxxxx\My Documents\backup"
Volume in drive C is D370_C
Volume Serial Number is C89E-70E8

Directory of C:\Users\xxxxxxx\My Documents\backup

11/21/2011 01:30 PM <DIR> .
11/21/2011 01:30 PM <DIR> ..
11/21/2011 01:30 PM <DIR> 2011-11-21_backup
0 File(s) 0 bytes
3 Dir(s) 28,082,577,408 bytes free

Read other 8 answers
RELEVANCY SCORE 119.2

I am trying to write a batch file that will copy my backup files to another drive. For example I currently have the file backed up to C:\Backup\movie backup
I want to be able to copy it to an external HDD: -
X:\Backup Folder\Movie Library, however each time I do this it overwrites the previous backup file.
I want to be able to copy this backup to a new folder each and every time, as follows: -
Today’s backup file would copy to:-
X:\Backup Folder\Movie Library\backup 03-Jul-2010 .......tomorrows would go to
X:\Backup Folder\Movie Library\backup 04-Jul-2010 etc
Can anyone help. I have been looking all day and can't find anything.

Thanx in advance

Jon
 

A:Batch File to copy to Date Stamped Folder

Welcome to TSG!

Use "X:\Backup Folder\Movie Library\backup%date%" as the destination folder name in your batch file. The %date% variable will be expanded with today's date
 

Read other 2 answers
RELEVANCY SCORE 118.8

I've been searching the web on how to accomplish this but am coming up empty handed so I am hoping someone here can help...

I want my batch file to read a random line from a text file into an environment variable - can this be done?

I am using Windows 2000.
 

A:Batch File -- Read Random Line from External File into an Environment Variable

Read other 6 answers
RELEVANCY SCORE 118.8

I am wondering if anyone can provide the equivalent to this linux script. When run against a text file with one entry per line being the name of a directory, it deletes the named directories.

On linux, I run this against the text list.
#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
rm -R $line
done < "$1"

I am not sure how to make it do the same for Windows. I can do this, but I'm hoping there's a way to delete based on what's in the text file. Also, wouldn't want it to prompt for deletion of each, but to just delete.

@echo on
cd \
cd %USERPROFILE%
dir /D /N 0
pause
for /D %%f in (XX*) do rmdir %%f /s
pause
%comspec% /k
pause


Thank you

Read other answers
RELEVANCY SCORE 118.8

How to create a batch file that will move files based on the file type?

My Requirement : I need a batch file to copy all .doc files in all my HardDisk to a removable disk say (Z: drive) . Can anyone make it possible using a batch file?Please...Its urgent...

A:How to create a batch file that will move files based on the file type

Download XXCopy
XXCOPY, A Versatile File Management Utility --- Boldly Extended Xcopy
This is a vastly improved and extended version of DOS XCopy
Sorry, can't remember the syntax, but its quite simple if you read the manuel carefully :-)
Put the command line in a .bat file and it will run

Read other 4 answers
RELEVANCY SCORE 118.8

I'm working on a batch file that will download a file I maintain, look for a string of text, and if it doesn't find the string, rename a file or folder, or change the file or folder's attributes to read-only.

I think I can handle the last part, and I already have the ftp part done, but I am having a hard time finding any good resource for the text string lookup/IF statement.

Any help is greatly appreciated. I'm new here, please excuse my ignorance if I am posting in the wrong area or violating any rules.

Thanks,
Jash
 

A:Batch file to compare text and rename file or driectory on fail

Read other 6 answers
RELEVANCY SCORE 118.8

I created this batch file to log certain users logins. It creates a text file to log in, but doesn't populate any of the data to it. Could someone please take a look at it and see what I did wrong. I'm new to writing batch files.

Thanks in advance. Here is the code.

@echo off
set target=JDoe
if %username% == target echo %username% %date% %time% %computername% >> c:\logfile.txt
 

A:Solved: Batch file creates text file but does not populate data to it

target is a variable. You have to surrournd it with %% like any other variable.
Code:

C:\>set target=Squashman

C:\>if %username% == %target% echo %username% %date% %time% %computername% >> c:
\logfile.txt

C:\>type logfile.txt
Squashman Fri 05/23/2008 10:34:14.74 BUMBLE-BEE

C:\>

 

Read other 3 answers