Over 1 million tech questions and answers.

Get ACL permissions from a text file enforced by a batch file in Windows XP

Q: Get ACL permissions from a text file enforced by a batch file in Windows XP

I've come into contact with Mandriva Linux. I know of a concept called standard permissions, that it provides. It's pretty convienient. I don't exactly know how it really works under the hood or anything, and I don't need to know exactly how it works right now either, even though it's probably available.

What I want to do, in effect, is create a feature pretty close to equivelant of this feature, only for Windows XP. I want to set standard permissions using a batch file. Whenever this batch file is run as administrator it can enforce the permissions. What are these permissions it enforces? Well, what I want is for these permissions to be gotten from a text file. The syntax in no way resembles the syntax of the Linux file I'm describing.

Basically the syntax is this:
The path is the path to a file or folder in exact syntax. The mode is one of the switches that can be given for XCACLS in the Windows Resource Kit thingy. This can be replace, edit, etc. The users are the user or group to add/replace/remove/etc, and there is a comma allowed so more than one user or group is allowed to be specified. The permissions are the permissions that you can specify in the utillity.

So the first thing the script needs to do, is call some program that safely detects whether or not the filesystem is NTFS or not. If the system is NOT NTFS, then it does nothing. If it's NTFS, then it continues to set the permissions. First of all, I can find no such program, but I know one must exist somewhere for free!

Next, it sets the permissions on the root of the drives mentioned to Everyone get's full control. That way there's no errors when setting the stuff. Finally, it gets the entire file's contents line by line executing the XCACLS command to set it giving it the proper parameters it needs.

So the second problem is how to parse the text file. If, however, there's a free program that already does all this for Windows XP, I'd be willing to try it instead though. But I can find no such program.

Now as long as the syntax is still reasonable and provides at least that information, I'd be willing to try an easier syntax to parse instead.

Preferred Solution: Get ACL permissions from a text file enforced by a batch file in Windows XP

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: Get ACL permissions from a text file enforced by a batch file in Windows XP

Read other 16 answers

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.
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 \
dir /D /N 0
for /D %%f in (XX*) do rmdir %%f /s
%comspec% /k

Thank you

Read other answers

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.

C:\>set target=Squashman

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

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



Read other 3 answers

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.


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

Read other 6 answers

Alright, so what I'm trying to do is list all the shortcuts & folders in the start menu and list all the shortcuts & folders on the desktop and put this into a text file. The reason is to get a full list of programs our teachers use before we re-image their machine and not all of their programs are listed in add/remove programs and not all programs make a folder in Program Files, that is why I'm trying to do it in this roundabout way. What I have so far is this:

@echo off
mkdir "p:\Program List"
DIR "c:\documents and settings\all users\start menu\*" /S/B/OD > "p:\Program List\%computername% Start Menu.txt"
DIR "c:\documents and settings\all users\desktop\*" /S/B/OD > "p:\Program List\%computername% Desktop.txt"

This works perfectly but the only problem is the file has these:
c:\documents and settings\all users\start menu\
c:\documents and settings\all users\desktop\

before each entry in the text file. Is there an easy way to remove these lines so the text files are easier to read? I've checked other sources and can't figure out how to get this to work...

A:[SOLVED] Delete text from .txt file in a batch file

Open the files in Notepad, click Edit, then replace, and enter the string C:\Documents and Settings\All Users\ and replace it with nothing (no entry).


Read other 10 answers

Okay, so basically, I have a whole list of links in a plain text Notepad file, each link on a seperate line. All I am wanting to do is to add a bit of text before each link, specifically: and a couple of spaces.

So this...

becomes this...

[SIZE=3] somelink.com[/SIZE]
By now you've probably already guessed what I'm trying to do here and what it's for.

So I am wanting some batch file code, executable in a .bat file, which basically reads a Notepad text file, and then add " " at the beginning of each line with text on it. I am guessing this is probably a very simple piece of code for someone with some knowledge of MS DOS and batch file code, but that most certainly isn't me, and the only batch files I have ever written have been with help like now.

Thanks for any and all help in advance with this, much appreciated.

A:Batch File To Read And Modify Text File

Read other 9 answers


I want to write a batch file to add the numbers. The inputs are in the text file. I need to add all the numbers in the text file that are in consequent lines. Please help me in doing that by giving an example.

Menaka B

A:Batch file that takes input from text file

Read other 7 answers

Anyone know how to take the contents of a text file, numbers only, calculate and then store them as a value? I'll be constantly adding to this text file and they need to be calculate. Like the balance of a bank but a little different.
Please and thanks!

A:Batch File, Calculating the Contents of a Text File

I think that would actually be very hard to do as the numbers in your text file are not integers but text and doing calculations would not be possible. Is there any reason you can't use a spreadsheet to do this?

Read other 10 answers


Can anyone tell me how to get part of a bacth file to read a line from a text file and then set it to a variable.

For example the file contains computername =computer1

how do i get the batch to read that and set computer1 to a variable that can be used within the batch file.

If possible what i would also like to be able to do is once set that to variable, compare it against the correct computer number and if incorrect go back into the batch file and set the line to the correct computer name

Any help is appreciated.


A:Batch File Read Line Of Text File

Read other 7 answers

I have a text file located at \\thedrive\a folder\another folder\log.txt. This file contains several lines of this kind of data "jdoe upgraded 09-20-2011 13:42:49.62".
I have a batch file located "d:\folderName" that needs to read the "log.txt" file and obtain the local computer user username if it is in the file. If it is not in the file then a file is to be copied to the d drive from \\thedrive\a folder\another folder\ to "d:\folderName" and then run the file. This is what I currently have
@Echo Off
SetLocal EnableDelayedExpansion
::This line is just in case n has been defined before the batch file is run
Set n=
Set _InputFile="\\thedrive\a folder\another folder\log.txt"
For /F "tokens=*" %%I IN (%_InputFile%) DO (
Set /a n+=1
Set _var!n!=%%I
but the log file is not read. If I move the "log.txt" off the network it works just fine. I cannot move the "log.txt" file as other processes use it nor can I copy it.

A:Batch file to read from a network text file

Because you have Quotes around your file name you need to use the USEBACKQ option.

Please use CODE tags when posting code.

@Echo Off
SetLocal EnableDelayedExpansion
::This line is just in case n has been defined before the batch file is run
Set n=
Set _InputFile="\\thedrive\a folder\another folder\log.txt"
For /F "usebackq tokens=*" %%I IN (%_InputFile%) DO (
Set /a n+=1
Set _var!n!=%%I


Read other 1 answers

I am trying to write a batch file that replaces a word in a text file with another word given as a batch parameter. I know of the FOR /F command to loop thru the lines. I know also about doing a simple string replacement. But I can't seem to piece it together. Can somebody help me?

A:Batch file to replace words in a text file

Read other 16 answers

Backround: I am a college student majoring in Information Technology with a focus in programming. I also work for my school's IT department as an IT associate. I have 4 years of experience dealing with hardware and software and have studied Net+ and A+ certification books.

Problem: At my school my boss, the IT Director, wants to schedule a batch file to run weekly that will delete items from the desktop and folders of the "Student" account on all of the student computers. He asked us associates to go around to every student computer with this batch file on a thumb drive and schedule the task. Seems simple enough right? The problem is we are talking upwards of 300 computers throughout the campus. I proposed a solution to him where we would use a script that would essentially consult a text document with the names of all of the student computers in it, then run the file.

I am 99% this can be done, I just have a very small amount of programming experience. If anyone has an answer or knows of an easier way to accomplish this I appreciate it. Thanks in advance.

EDIT: All student workstations are running Windows XP SP2

A:VB Script to Run a Batch File and Utilize a Text File

Read other 16 answers


I need some kind of program/batch file that will place the current IP address (I have dynamic so it changes every two hours) in a text file that I have specified. The text file would have to be in this way:
Click to expand...

Click to expand...

I am using graburl to update my host of my location, so I thou ht that I could use graburl to do something like this. If it is not possible to include date and time in the text file it is not completely required. However the latest IP address would have to be at the top of the list not at the bottom (This must also happen even if date and time columns are in the list).

Any help would be great.

A:Batch file that will put current IP in a text file

Read other 12 answers

I had a Windows 10 laptop with an external USB hard drive attached. The external drive has a folder with hundreds of jpg images. The laptop failed and is no longer usable. I connected the external drive to a Windows 7 desktop and from there I can see the folder and all the files, but under Windows 7 I'm told I do not have permissions to access any of them. I don't even see the thumbnail images in the folder view.

I have found I can set the permissions such that the files are accessible again by doing the following:

1. Right-click on file, select Properties
2. Click Security tab
3. Click Continue button, get screen that says "Unable to display current owner"
4. Click Other users or groups button
5. In Select User or Group dialog, enter object name "Everyone". Click OK to close and return to Advanced Security Settings box
6. Click OK on Advanced Security Settings Box
7. Click OK to acknowledge having to close and reopen properties
8. Click OK to close properties dialog, then right-click on file again
9. Click Security tab, then Edit
10.Click Add
11.In Select User or Group dialog, enter object name "Everyone". Click OK to close and return to Advanced Security Settings box
12.Click OK on Advanced Security Settings Box
13.Click OK in Properties dialog to dismiss.


I wouldn't mind doing this for a few files, but as I said this folder has hundreds of images in it. If I select more than one file and right-click for properties, I don't se... Read more

A:Is batch-updating of File Permissions possible?

Try the Take Ownership via Context Menu. It's a registry mod that allows you to right click on a file or folder and select Take Ownership.

See here: Add "Take Ownership" to Context Menu of Files, Folders, and Drives in Windows

Read other 5 answers

Just recently there was a batch file permissions problem posted here. I'm also trying to run a command window, but my problem is a bit different.

I have a batch file that cleans out programs' cache before shutting down the system, that I use every night to sign off. Since I demoted my normal user account from Admin, I'm incurring a permissions problem. The batch will fire, but only after I give it the UAC OK. That's as expected.

I'd like to eliminate the need for the UAC OK for this program. But whether I give ownership of the Batch file to the super-admin or to my user account, the Run as administrator option on the Properties/Compatibility tab is grayed out. There simply seems to be no way to give this program residual admin rights.

I'd like to be able to crack this nut, not just for this program but in order to learn more about how permissions work.


A:Another batch file permissions problem

Use Task Scheduler to run the batch file using a higher privileged account when you log off.
Or have it run when you log on.

Read other 6 answers

I need to script/batch a way of changing file permissions on a whole directory tree. Any ideas on how to do this?

Read other answers

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:


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.

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

So I have a batch file set up to create folders and subfolders. These folders are created on a shared server that several employees access. The idea is to run the batch to create a set of folders for each new customer. This keeps all of the files for the customer in one spot rather than spreading it out in a folder for each department then the customer. Hopefully everyone followed that.

The batch file creates my folders perfectly except no one else can access them. The permissions are denied for all users besides me. This is a problem because we have several employees trying to access the new customer folder I have created.

I want to be able to run the batch and create folders that automatically allow anyone to delete, rename, add to, move, etc. All of these permissions are allowed when I manually create the folders. The idea is that anyone in the company can run the batch to create a customer folder and anyone else can edit it.

Any ideas?

A:Giving Automatic Permissions to Folders Created Using a Batch File


I'm not familiar with the option, but using the ICACLS command will allow you to modify the permissions.

C:\Windows\system32>icacls /?

ICACLS name /save aclfile [/T] [/C] [/L] [/Q]
stores the DACLs for the files and folders that match the name
into aclfile for later use with /restore. Note that SACLs,
owner, or integrity labels are not saved.

ICACLS directory [/substitute SidOld SidNew [...]] /restore aclfile
[/C] [/L] [/Q]
applies the stored DACLs to files in directory.

ICACLS name /setowner user [/T] [/C] [/L] [/Q]
changes the owner of all matching names. This option does not
force a change of ownership; use the takeown.exe utility for
that purpose.

ICACLS name /findsid Sid [/T] [/C] [/L] [/Q]
finds all matching names that contain an ACL
explicitly mentioning Sid.

ICACLS name /verify [/T] [/C] [/L] [/Q]
finds all files whose ACL is not in canonical form or whose
lengths are inconsistent with ACE counts.

ICACLS name /reset [/T] [/C] [/L] [/Q]
replaces ACLs with default inherited ACLs for all matching files.

ICACLS name [/grant[:r] Sid:perm[...]]
[/deny Sid:perm [...]]
[/remove[:g|:d]] Sid[...]] [/T] [/C] [/L] [/Q]
[/setintegritylevel Level:policy[...]]

/grant[:r] Sid:perm grants the specified user access rights. With :r,
the permissions replace any previouly granted explicit permissions.
Without :r, the permissions are added to any previously ... Read more

Read other 6 answers

I am trying to create a task using a batch file which i can then add to my windows task manager so that i can schedule it run every 7 days.

I need the file to delet anything which is contained within the scanned documents folder. The folder is located on a network and shared by other users.

The code that i have so far is

set "folder=\\IVNKING\Shared Files\Scanned Documents"
pushd "%folder%"
for /d %%i in ('*') do rmdir "%%i" /q

Does anybody know if this will delete only the contents of the scanned documents folder or if it will delete anything in other folders in the path.

Read other answers

There is a software which
will generate a text file called PXI connections in the C disk after installing. I have installed it in 7 computers, in 2 of which the generated text file can't be modified. Even after changing the permissions in the security there is no use. All computers
are configured by windows 7 system. Why and how of that question?

Read other answers

There is a software which will generate a text file called PXI connections
in the C disk after installing. I have installed it in 7 computers, in 2 of which the generated text file can't be modified. Even after changing the permissions in the security there is no use. All computers are configured by windows 7 system. Why and how
of that question?

Read other answers

Dear all,

I am currently running a batch file that examines a backup folder that is added to at the end of each previous day. Currently the batch file uses 'findstr' to examine the original text file (created using the 'dir' command) and filters out the previous days dates to a new text file.
However, at present, the final text file starts with the names of all folders within the backup folder, then the names of folders within these folders, then files within each of these folders:

Backup_folder --> folder_1 --> folder_A --> file_1A
Backup_folder --> folder_2 --> folder_B --> file_2B

Producing a text list =
folder_2 etc
folder_B etc
file_2B etc

However, ideally what I would like is to have the folder names of folders within the backup folder and then the number of folders and number of files within each of these folders directly after each folder name . . .

Thanks in advance for any help!

A:Batch file --> text list production help

Read other 10 answers

Dear friends, I am not a programmer by any chance and in a situation where I need some immediate help. I am grateful for all taking the time to read and respond.

I have a bunch of text in a text file and every so often there are 4 letter words occuring in all uppercase. I want to extract these 4 letter words and output them into an excel or csv file (which I can import in excel). I will list certain occurrences so you get an idea.

&FOKP blablabla
bla bla cbdfjc sjdkjscxj SDGF cnikdjnidbnv
bkabkabla ABCDEwhatever

I want to extract ABCD, FOKP and SDGF here, and not ABCDE. The % sign is actually that sign"%". Some places this changes to other characters such as # or $ or @; but I am interested in the 4 letters occurring together and ONLY 4 letters, they occur all in caps and/or followed by spaces and/or characters and/or other text. If in any place there is a text such as &&ABCDEblabla, then I want it to ignore this info as I am only interested in 4 uppercase letters occuring together and no more or no less.

If I am confusing you then please let me know and I can try to explain more. I am in very urgent need of this and have tried everyone at my university, but no help. I am very grateful for your time and hope you can provide a script or lead me in the right direction. Thanks a million again!

A:batch file for text data extraction

Not something that can easily be done in pure batch. You would be better off doing this with a utility or programming language that has a more robust regular expression capability. I am going to alert someone to look at this thread that will have a better idea if this can be done with a hybrid batch and jscript solution. That will be as close as it gets without using a 3rd party utility or another programming language.

Read other 3 answers


I have multiple text files (very large) containing text split by the delimiter $. Unforunately some of the data contains the dollar sign which is preventing me uploading the file into my data analysis tool. I can identify the difference between a delimiter and a standard dollar sign as the delimiter is always preceded by -} ie -}$. I cannot set this as the delimiter as it affects the way the data is read in my tool.

I need to alter the delimiter from $ to $$.

Can you help me find a way to automatically (using a .bat file) open the text files in the directory and replace ever instance of -}$ with -}$$?

Many thanks for your help

A:Batch Find and Replace on a text file

Welcome to TSG!

Do the files contain any of these characters:
If so, it would be much easier to use something like Replace Text, which can so a Search and Replace on multiple files. I haven't used it much so I can't be 100% certain it doesn't have issues with some characters though.
SwissFileKnife can do it from a command line. It does not make a copy, so backup the files first just in case.
This will replace -}$ with -}$$ in all .txt files in the C:\Test1 folder and it's subfolders as well. If you don't want to process subfolders add -nosub

sfk rep -text /[COLOR=Red]-}$[/COLOR]/[COLOR=Magenta]-}$$[/COLOR]/ -dir [COLOR=DarkRed]C:\Test1[/COLOR] -file [COLOR=Blue].txt[/COLOR] -yes
If your files don't have any of those characters, this batch file should work:

SetLocal EnableExtensions
Set _Source=C:\test1
Set _Dest=C:\Test2
If NOT Exist "%_Dest%" MD "%_Dest%"
PushD %_Source%
For /F "Tokens=1 Delims=" %%A In ('Dir /A-D /B *.txt') Do (
If Exist "%_Dest%\%%A" Del "%_Dest%\%%A"
For /F "Usebackq Tokens=1 Delims=" %%I In ("%%A") Do Call :_Sub "%%I" "%%A"
Set _tmp=%~1
>>"%_Dest%\%~2" Echo.%_tmp:-}$=-}$$%
Goto :EOF


Read other 2 answers

I am currently writing a batch file, and I need to scan two variables from a very short text file, that goes something like this:

lineof text1
[email protected]
I need to scan these two lines into two different variables. Specifically, I want to set %usrnm% to lineof text1 and %usreml% to [email protected]. I did do a thorough Goole search on this, and I tried code like

SetLocal EnableDelayedExpansion
::This line is just in case n has been defined before the batch file is run
Set n=
Set _InputFile=config.txt
For /F "tokens=*" %%I IN (%_InputFile%) DO (
Set /a n+=1
Set _var!n!=%%I
echo %usrnm%
but when I did this, I got the strange unwanted message: "Echo is off" and no variable was printed out (second to last line: echo %usrnm%). I tried the same with %usreml%, then with both, which printed the same message, and tried echo testing. . ., which printed out fine. If it helps, I'm using Windows 7, though I want this to be compatible with XP SP3.
Any ideas? Any help would be appreciated!

A:Solved: Scan text into batch program from .txt file?

Welcome to TSG!

You never defined usrnm anyplace, so your Echo statement is just that; Echo, which displays the state of the Echo setting. You have to define the variables with the ones you set inside the loop after you exit the loop.
Give this a try:

SetLocal EnableDelayedExpansion
::This line is just in case n has been defined before the batch file is run
Set n=
Set _InputFile=config.txt
For /F "tokens=*" %%I In (%_InputFile%) Do (
Set /a n+=1
Set _var!n!=%%I
Set Usrnm=%_var1%
Set Usreml=%_var2%
Echo Usrnm=%Usrnm%
Echo Usreml=%Usreml%

Read other 3 answers

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

Hi my friend,
Everyday a lot of new text files are created in a specific directory by an electronic invoice software. Nobody know why but in the end of the file there are a lot of blank spaces and it is causing a lot of problems when we're going to process all of them.
I removed these blank spaces from the end of the files manually and all files were processed well.
So I'd like to ask if somebody could help me to create a batch to remove double (or more) blank spaces from the files.
Thanks so much

A:Batch File to Remove Blank Space in Text Files

This worked for me under XP, I found it on another site. On the command line use the original file name and a new name to represent %1 and %2.

For example: CleanFile.bat OriginalText.txt NewFile.txt

@Echo Off
For /F "tokens=* delims=" %%A in (%1) Do Echo %%A >> %2

Read other 1 answers

Hello All,

I am looking for something to help me in my work. I have to keep line counts in text and CSV files in a log. I was wondering if it was possible to do this with a batch file?

Here is what i would like for it to do:
Open the DOS window in XP.
Drag the Bat file to the dos window
Drag the file needing to be counted to the same window(or copy the network address), click enter
and have a line count

Currently I use KEdit to get this information from the status bar (size) but thought a batch file might be easier (and quicker).

Can someone help me?

Tannks a bunch

A:Solved: Batch File for Counting Lines in Text or CSV files

Did some Googling around, never really thought of doing this in a batch file. I found a VBscript alternative you might be able to use from command line though.


here's a vbscript alternative:


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
myFile = objArgs(0)
Set objFile = objFSO.OpenTextFile(myFile,1)
Do Until objFile.AtEndOfLine
line = objFile.Line
WScript.Echo "Line count of", myFile , "is", line

cscript myscript myfile

The link above is the link to the page where I found this information, wanted to give credit where credit is due. With this script you could just call the script and give it the parameter my file from command line. If you really wanted a batch, you could easily create a batch that echo's each of those lines into a temp.vbs, calls the temp.vbs with a parameter %myfile using the "cscript myscript myfile" command then "del temp.vbs" at the end. Seems very redundant and pointless though.

Hope the VBS helps you.


Read other 3 answers


I would like to have a text file that stores a number, lets say 2000. I want my batch script to grab the number from that file, and put it into a variable. The script will then do stuff with that variable and once it is finished, add 1 to it (don't know how easy that bit is). Then I want the script to write this number (2001) back into the text file, overwriting the old number.

So basically the contents of the text file would go from 2000, to 2001, to 2002, etc each time the batch file is run.

Would anyone be able to point in the right direction for this?

Any help is highly appreciated.

A:Solved: batch programming: reading and writing from/to text file?


@for /f %%a in (file.txt) do @set /a var=%%a+1

Read other 2 answers

I'm starting to worry that this isn't possible in a win batch file:

I have two text files, text1 and text2, each file contains multiple short lines of text, like this:
I would like to read the first line of text1 and use that text to search for the same string in text2. If the string is NOT found, I would like to stop and call an external batch file. If the string IS found, drop to the second line of text1 and repeat the search, repeating the process until another unique string is found or eof is reached.

A:Solved: Batch - stepping through a text file for separate variables

Read other 7 answers


I have a file in a folder on a network drive whose path is : "\\sql\imp\ssis"

I need a windows batch file that looks into the above folder for a file with a name like : "abcd_03052012_84373.txt" .

The above file name has a date embedded in it in "ddmmyyyy" format. I want that to be extracted and put into a variable or a file somewhere so that I can read that later and store into a sql table.

Please help.

A:Solved: Extract Date from File Name - Using Windows Batch File

Read other 6 answers

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

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.


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.

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

Read other 1 answers

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


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

i need a list of everything on my hard drive i can access in a text file without manually pounding the folder/sub folder and contents names into notepad is there anyway this can be achieved?

A:Windows file contents to text file

See this link: MS-DOS command redirection operators

Read other 6 answers

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

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

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

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

During a TrendMicro virus scan, it found an archive that was infected. A quick check of the archive (Which I'd grabbed months before, but never ran) showed it was actually an application, so I went to shift+del the file (No sense dumping a virus into the recycle bin), and poof it's gone.

Then I went to delete the folder it was in, but... it wouldn't let me. Told me I didn't have the permissions to do so. A quick check of the folder's contents revealed the virus/app was back, as if it had never been deleted.

If I try doing a regular delete, it tells me Destination Folder Access Denied.

So I started poking around the file's security properties.
"Unable to display current owner."

I tried changing the owner, but it wouldn't let me do that.
I downloaded Unlocker, right-clicked on the file and unlocked it, but nothing seemed to happen, and same results when I try to delete it.

I'm running Vista 32-bit, not connected to a local network (Just one computer), and I'd really like to delete this virus/app off my machine. TrendMicro was unable to get rid of it, and I can't seem to get rid of it either.

A:Solved: Cannot delete file / No Permissions - Unable to display current owner of file

Ha, nevermind. Unlocker just took an enormous amount of time in actually starting up, and turns out the virus scanner had a process linked to the file. So, problem solved. Nothing to see here.

Read other 1 answers

Problem Steps Recorder Error - You do not have the necessary file-system permissions to create the specified output file.

Read other answers

If anyone can help it will be greatly appreciated,I am taking A + Essentials and my instructor isn't explaining it,

A:How to switch file type name to contents using a batch file for notepad

If you are as it appears you are paying for a Course for a Comptia A+ certification and the teacher isn't doing the job why haven't you gone to the school and asked them to switch you to a course with a different instructor? Or Demand a refund?

When I got my A+ back in 2000 it wasn't that hard to pass. I believe it was two tests and I was over 95% on both with no training course. I was experienced in computers and doing things and They did have a sample test as I recall it.

And of course that old standby Google

I'm afraid I can't help you further as the tests have changed a lot over the years.

Read other 1 answers

Hi there forum,

how do you change the Visual effects using a batch file or registry file.



Read other answers

Hi there forum,

how do you change the Visual effects using a batch file or registry file.



A:How to change visual effects using batch file or registry file?

Hello Edward, and welcome to Ten Forums.

The links in the blue note box under OPTION FOUR in the tutorial below may be able to help with this.

Visual Effects Settings - Change in Windows 10

Read other answers

Hi all,

Please help!! I'm having a problem to copy some files from a folder.
My folder have lots of files and is there any way for me to write a batch file to copy only files according to "date modified"? For example last week files or yesterday files.

Please help!! Urgent!!!
Thank you.

A:Urgent!! Copy file by date modified using Batch File.

Take a look at XXCOPY: http://www.xxcopy.com/index.htm

Read other 2 answers

Hi Guys,

I want to make one batch file which daily copies yesterday's files from one folder & paste it to another folder.

C:/111 folder has following files.
1.zip had yesterday's date
2.zip had yesterday's date
3.zip had last sunday's date

now, when i will run batch file today, it only copies 1.zip & 2.zip & move to another folder C:/222

So C:/222 contains following
1.zip had yesterday's date
2.zip had yesterday's date

Please note , i have to run this batch file daily which should not require any changes.

Read other answers