We help IT Professionals succeed at work.

Microsoft DOS

13K

Solutions

12K

Contributors

Microsoft Disk Operating System (MS-DOS) was an operating system for x86-based personal computers, and traces of it are still found in the Windows operating system. DOS is still used in some embedded systems and for certain legacy 16-bit networks.

This is probably easy for someone who is great at batch scripting, but I can't seem to figure it out.

I receive a monthly file that is sent to me via FTP.  The filename is similar to this: Monthly_Y_20130514_X.zip (20130514 represents a date stamp that will change to when the file is uploaded)

So I need to parse the filename and extract out the 2013 and the 05.  The tricky part, is that the file has to go in a folder for the PRIOR month, so for that example above, I'd need to unzip it to a folder like this:

c:\Files\2013\04

Not too tricky now, but January has me all confused.  A file such as Monthly_Y_20140105_X.zip would go into a c:\Files\2013\12 folder.

The steps as I see it are this:

1.  Parse filename, put the year in one variable and the month in another.
2.  Take the month variable, and subtract 1 unless it's a 1.  In that case, make it a 12 instead and subtract 1 from the year as well.
3.  Check to see if the year folder exists, create it if not.
4.  Check to see if the month folder exists, create it if not.
5.  Unzip the file into the folder.

Would be most appreciative if someone can help with this...  If more info is needed, please just ask.

Thanks!

Josh
0
Have a folder called logs  

which has file since last 30 days i want to delete all the .Logs sorted by timestamp  and delete previous 15 days of logs file  

i want to make a Batch file  and run the cron every  1 month to delete the 15 days logs

Can any one help

Sorting dir /OD   works  and no idea how to do the next delete
0
I want to make a folder in my d drive and want to make it like bootdisk. I want to make it as cdrom dos bootdisk though it is a folder. Is it possible?  If possible then how to do it? Please advise.
Regards
0
how to create a script file for a user to connect to an ftp site, so that when the user clicks on the .bat file the ftp site should open.
I tried creating like below, doesn't work;

cmd
open ftp XX.XX.XX.XX
UserName
Password

Would like to learn more about creating script in windows
0
We are creating a script that will disable all network adapters on an infected computer. However, we are concerned that the user may have cached local admin rights, and can circumvent the action and re-enable the NIC.

I am looking for a DOS command (executed as system) that will remove EVERYONE from the local admin group on the device. The next action will be to re-image the device, so we aren't that concerned about not having admin access after the fact.

I know this is possible with VB, but we need to issue the command without uploading a file (.VBS)

Any help would be greatly appreciated!

Thank you!
0
Well, a data transfer I've been trying to perform on a client pc went astray and now we are trying to clean it up. It is on a Windows XP machine

The problem I ran into while trying to copy his data was >255 path/filename issues so I couldn't' get a copy to complete without leaving files behind because of the >255 thing.
I used a utility called Teracopy to try since it would give me a list of errors during the copy process. I took a couple of stabs but never finished because I like to see copy jobs have the same amount of files/folders in the destination folder as are in the source folder.

Now, I realize I could have mapped  a drive deep in the path to eliminate a lot of characters, but it's too late for that because my client tried to do a move to a new directory and the result was that most files/folders went, some stayed behind, others aren't in either location.

So.....what I have decided to do is take the 4 different collections of files we have of his data (1 from backup, one from a copy I did just a couple of days before his move, and one from his move/source folders) and copy one on top of the other allowing newer files to overwrite older files, thinking this will leave him in the best possible situation considering the circumstances.

What I'd like to find out from you fine people at EE is what is the best way to do this. I'm thinking XCOPY might do the trick but I've never really used it. I could just go with windows explorer but it is soooo slow.

I'm …
0
I'm trying to figure out a way to automate a script that runs an application for decrypting and converting over one thousand audio files.

The script is rather simple. From the directory in which the application is located I just enter from a command line: "application.exe {inputfile.i3r} {outputfile.wav} {key}"

The inputfile and outputfile should have the same names the formats will just be different. And they should end up in the same directory.

The problems are:
1. the file names are 46 characters in length
2. the files are spread across thousands individual directories
3. too many files to do so manually

I guess what I need is a process that can crawl the various directories, get the UNC path of each respective file including the file's name input the information into the script listed above and execute the script.

Any suggestions would be greatly appreciated.

Thanks!!
0
Summary: Move end of month files, delete the rest, except the most recent 30.

Details: I have a situation where I have 4 disks with robocopied data on them. These drives have data as far back as 2009. Most of them are SQL files and fortunately the naming convention is consistent, with a date and time added to the name of the database. I have a partial solution to ensure that I keep the most recent 30 files (this month's files) from a previous question that dragon-it solved for me. However I now need to add the complexity of going through all these drives and sub-folders and delete all the files except those that are the end of the month--the month end files need to be moved to E:\SQL-EndOfMonth\Databases\Database-name folder. I have a similar issue with QuickBooks files but once I can find a solution to this SQL files issue I can adjust that accordingly.

The folders the files are copied to are
Directory of D:\SQL-E\SQL-Backup\Databases with subfolders
<DIR>          Dynamics
<DIR>          HFI
<DIR>          Master
In each of these folders are hundreds of files--I am attaching a few text files with the results of a "dir" of these sub-folders for you to see the naming convention.

I will use the following to keep the most recent 30 but if you have a better solution great
set Dir1=D:\SQL-E\SQL-Backup\Databases\HFI
set Dir2=D:\SQL-E\SQL-Backup\Databases\Dynamics
set Dir3=D:\SQL-E\SQL-Backup\Databases\Master

for /F "tokens=* skip=30" %%A in ('dir /b /a-d /o-d …
0
Hi all, I have some batch files for ftp that generate log files. The logs are taking up space, so I want to add a command in the existing ftp batch files to look 2 months back, then delete the log files from the period. There is a cmd file called datemath.cmd that I would like to use to calculate the date for it to delete the log files. I would appreciate some help with the command that would:
1. Using datemath.cmd, look for the log files or any file created two month ago
2. If any exist, delete them.
I welcome all assistance, and thanks in advance.
0
I have written a basic .bat file to start a program when win7 starts and have put it in the c:\program data\microsoft\windows\start menu\programs\startup folder.  It works OK.

My problem is that the cmd window remains there until I exit from the program

How do I get the cmd window to disappear.

The batch file is:
@echo off
c:\rest\rest.exe /PWmanger /office2003

I tried adding exit as a last line but nothing
0
is there a command in dos or a bat file that can be made to get all the files produced from a computer on a specific date regardless of where the file might have been stored? IN other words we had a user create some notes on one of the pcs logged in as a domain user and save a file (he can't remember the name of the file). So, im trying to search the computer for that specific date and see if any files were made during that time and where they might have been stored. Thanks!

i tried something like this but didn't find anything
xcopy "\documents and settings\*.doc" /l /s /d:04-04-2013 .

Open in new window

0
I WANT TO WRITE A BAT FILE ASK USER FOR INPUT

IF HE ENTER  " 1 " : netsh -f c:\netcfg1.txt
ELSE IF VALUE IS " 2 " netsh -f c:\netcfg2.txt

:: DeCLARE variable %O%
SET "O="
SET /P "O=Set Your Choice And Press Enter: "

IF "%O%"=="1" GOTO Hide
IF "%O%"=="2" GOTO Show
IF "%O%"=="3" GOTO Exit

:Hide
ECHO Hide

:Show
ECHO SHOW

:Exit
ECHO EXIT

THE RESULT IS PRINTING ALL RESULT AND THE CMD PROMT WINDOWS WILL CLOSE DIRECTLY...

HELP PLEASE
0
Hi all,

I wish to create a basic icon changer is delphi but I could if needed have it working in dos then I can always sort it for delphi.

Anyhow I wish to load a .exe file into my icon changer, choose from a list of around 5 icons, then be promopted for new file name, so user would type 555 and it would auto save as 555.exe with thenew selected icon.

This should be visible on another pc.

Now, in delphi I can browser and locate files fine and can whip a program to do that but I need help with the rest.

many many thanks.
0
I have a Windows 2000 server that I need to copy files over to a Windows 2003 machine.  I know in 2003 and later I could just use robocopy, but what is a similar program for Windows 2000 so that I can get the files off the server before it crashes?  The machine has no USB at all, so an external hard drive is out of the question.
0
I need a batch file that will test for a certain gateway (192.168.1.1) and if positive, then continue on to another section of the file (goto :continue) or even call another batch file (call continue.bat).

I assume this involved parsing ipinfo?
0
i have some windows batch files that i need to migrate to a 64 bit server.

the program i had been using to set the time stamp variables with in the batch program was XSET

using the following

xset32 curdatetime date mmddhhmm

this would put the current date and time in the batch variable  curdatetime

i would then use it to rename transfer files like this...

copy camat01.txt camatdaily%curdatetime%.txt


i need this functionality to work in 64 bit os.

it doesnt have to be xset  ....
i just needthe dos commands to set the time date variable



it was running on windows server 2003
the current server is windows server 2008 R2
0
Greetings,
I have a folder of zip files.  zip1.zip, zip2.zip
I need, in a single windows os command, to unzip using the unzip command, extract the contents of all the zip files into their respective folders with the zip filename as the folder name.

Similiar to when winzip has "extract to folders as filenames" option in windows, but from command line.

Thanks,
0
Hi guys, I'm after a batch script which will check the current IP of the machine and if it falls within a list of certain ranges, go to another section of the script.

So something like this:
IPrange1 = 1.1.1.x
IPrange2 = 1.1.2.x
IPrange3 = 1.1.3.x
If current IP address is in IPrange1 goto range1
If current IP address is in IPrange2 goto range2
If current IP address is in IPrange3 goto range3
.....
0
This is driving me batty.  

Trying to write a command that uses a source file, a target folder, and an optional -c parameter (-c creates the folder if it doesn't exist).

The intent is to create a target folder using the -c switch but if someone enters incorrect syntax for a folder path, it sets a flag (TargetMissing) to true and enables the final check (If TargetMissing==True goto TargetNotExist) to evaluate and go to the error location... but when I try to reference the "reset" TargetMissing variable (using !) it doesn't work...

It's not been that long since I did batch stuff... what am I missing?

(host PC is Win7 Enterprise x64 and things like this have worked in the past in other scripts!)

@Echo off
setlocal enabledelayedexpansion enableextensions
REM Tried without the enableextensions part too.
Set Target=%2
IF "%target%"=="" Goto NoTargetSpecified
If "%target:~-1%" NEQ "\" Set Target=%Target%\
If Not Exist %Target% (
	Set TargetMissing=True
	REM Next line for debugging purposes
	Echo %TargetMissing% !TargetMissing!
	If /i "%3"=="/c" (
		mkdir "%target%"
		If Not Exist %Target% Goto ErrorCreatingTarget
		Set TargetMissing=False
		REM Next line for debugging purposes
		Echo %TargetMissing% !TargetMissing!
	)
	If /i "%3"=="-c" (
		mkdir "%target%"
		If Not Exist %Target% Goto ErrorCreatingTarget
		Set TargetMissing=False
		REM Next line for debugging purposes
		Echo %TargetMissing% !TargetMissing!
	)
	If "%TargetMissing%"=="True" Goto TargetNotExist
)

Open in new window

0
I have many folders and I need to know the folder creation date. I also need to backup and move these folders. So, I think I would be wise just to place the folder creation date in the name so I don't have to worry about the creation date getting changed when I move the folders.

I need a DOS command line command to read the oldest file within a directory then add the date of the oldest file to the directory. I would like to run this batch file from a parent directory so that it performs the above on a few hundred subdirectories.
0
I have a csv file with 360,000 lines of files that I need to copy from one share to another share.

example of the text file
\\Servername\ulrarchive\\21\08\62\21086254.doc

I need to copy them to another share \\newserver\archiveD\

However I need to retain the folder structure below the archiveD folder
example
\\newserver\archiveD\21\08\62\21086254.doc

I have looked at robocopy and xcopy commands but they dont seem to fit the bill.

Anyone got any other suggestions.

Regards
Karl
0
Presently have a cmd script that takes a list of machines and pings them.  We run this script fo rthree months and that remove any that have not been pings in those three months.
:: DEFINE FINENAME FOR NODE LIST
set logfile=CheckNode.txt
set VerifiedNodes=VerifiedNodes.txt

:: GET CURRENT "VERSION" OF THE CHECKNODE DIRECTORY THAT IS RUNNING
for /F "delims=\ tokens=4" %%i in ('cd') do set cnver=%%i

:start
:: CHECK TO SEE IF THE PROGRAM SHOULD COME TO CLEAN STOP
if exist check.stop goto :end

:: CHECK TO SEE IF THE LOG FILE THAT DISPLAYS NODES IN LIST IS RUNNING ON HOST MACHINE
pslist |%systemroot%\system32\find "tail"
if %errorlevel% GTR 0 start "CheckNode Log" tail -f %logfile%.log

:: IF THERE IS A GOOD NODE LIST COPY IT AS AN ARCHIVE
if exist %logfile% copy %logfile% *.last

:: COPY THE RESULT SET NODE LIST FROM LAST RUN TO BE SOURCE LIST FOR THIS RUN
if exist %logfile% copy %logfile% nodes.txt

:: DELETE THE RESULT SET FROM LAST RUN - THIS KEEPS IT FROM BEING APPENDED
if exist %logfile% del %logfile%

:: WRITE START MESSAGE TO LOG FILE
now "%COMPUTERNAME% CheckNode Starting" >> %logfile%.log

:: GET NODE NAME TO CHECK - THIS LOOP CONTINUES THROUGH ENTIRE NODE LIST
for /F %%i IN (nodes.txt) DO set node=%%i & call :SeeAlive

:: WRITE COMPLETED MESSAGE TO LOG FILE
now "%COMPUTERNAME% CheckNode Ending" >> %logfile%.log

:: WRITE NODE COUNT REULSTS MESSAGE TO LOG FILE
%systemroot%\system32\find "@@@" %logfile% /V /C >> %logfile%.log

:: COPY THE LAST NODE LIST UP TO 

Open in new window

0
I created this batch script a while back.

Things have now changed as there are other files with different names but with he smae extension that need to be copied to a different location and then renamed.

How can I modify the script to find each file in the directory, copy to destination and then copy and rename with the date?

Originally, there was one file in this folder but now they have started creating multiple files with different names.

@ echo off

REM - Create Date string
set Today=%date:~10,4%%date:~4<wbr ></wbr>,2%%date:~<wbr ></wbr>7,2%


echo todays date is %today%

if not exist e:\%computername% mkdir e:\%computername%

copy c:\files\*.txt e:\%computername%\fileName-%today%.ext

Open in new window

0
i want to run serveral mvn build commands sequentially.

cd..
start /wait mvn clean install -DskipTests
cd dbaccess
start /wait mvn clean
mvn integration-test

with start command i can do that, but it always open a new window, and i have to close the window before the next command runs.  also i have to tell DOS that i am not terminating the whole run when i close the window.  is there a way to:

1) call start without new window (i tried /b but it just stops after the first start command is done)
2) automatically continue to the next command without any manual actions on my part?

thanks.
0
How can I do write a DOS command using an IF-Else statement that will accomplish this:

If folder ABC contains a sub-folder named XYZ AND only folder XYZ, remove folder ABC and all sub-folders.  If however folder ABC contains any other folder in addition to XYZ, remove only folder XYZ.
0

Microsoft DOS

13K

Solutions

12K

Contributors

Microsoft Disk Operating System (MS-DOS) was an operating system for x86-based personal computers, and traces of it are still found in the Windows operating system. DOS is still used in some embedded systems and for certain legacy 16-bit networks.