Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x

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.

Share tech news, updates, or what's on your mind.

Sign up to Post

So here's the data I am looking at..I have a single folder files named this way:
file one (1).ext
file one (2).ext
file one (3).ext
file two 1.ext
file two 2.ext
file two 3.ext
file three a.ext
file three b.ext
file three c.ext ... etc etc

There are about 250,000 of these files in a single folder. I am trying to create a batch file where it will read the name of the file and create a folder based off of the text thats the same and stops when it reaches where the file is different and moves on to the next folder. Then copies the files into the created folder.

For example in the set above, I would end up with three folders: file one, file two and file the each with the 3 corresponding files moved to the correct folder. I came up with as much below but I cant figure out a way to get it to stop reading the file name when it reaches the "(" or the number or the different letter or whatever may be different in the file name. What I end up with is a folder for each file (full file name) and the corresponding file in that folder.

Heres my code:

@echo off
setlocal enabledelayedexpansion
for %%A in (*.ext) do (
   echo file found  %%A
   for /f "delims=" %%B in ("%%A") do set fname=%%~nB
   for /f "delims=" %%C in ("%%A") do set fextn=%%~xC
   for /f "tokens=1* delims=_" %%D in ("!fname!") do set folname=%%D
   echo folder name !folname!
   if not exist "!folname!" (
      echo Folder !folname! does not exist, creating
      md "!folname!"
   ) else (
 …
0
Free recovery tool for Microsoft Active Directory
LVL 1
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Hello,

what I would like is a batch file that will get the folder structure of the drive into a menu structure so that you can select the folder you want to go into, and once you select a folder from the menu, the subfolders of that folder would then be listed in a menu as well, and so on and so forth as deep into the folder structure as you want to drill down to. And in each menu would have a "backup current folder level" and a "list all contents of current folder" and if possible include a "go to previous folder" option.

 Basically I would like to run the batch file and be given a menu of the folders only of the c drive, then be given an option to either backup the current folder, list the files of the current folder in case I wanna to only backup one file from that folder, or select a subfolder and then be given the same options with the addition of the go to previous folder option for subfolders.

 I've tried and tried to write something like this but I'm not a strong batch script writer and just can't get anywhere with it.

 Thank you very much in advance for your help,
Ryan
0
With robocopy, is it possible to move any files from the destination to another folder whenever the source file has been removed ?

1. Any files / folders in source will be synchronously exactly with that in destination.
2. Files / folders that are removed from the source will be moved to another folder

Thx
0
I am using this type of batch file command

SET date=%date:~10,4%-%date:~4,2%-%date:~7,2%
set SAVESTAMP=%TIME::=-%

echo f | xcopy /f /y "C:\path\filename.txt" "D:\archive\filename%date%_%SAVESTAMP%.txt"

And it is creating the same file in my archive from 2-3 times. I've checked the original directory and there is only the one filename.txt file.

They all have the same date modified and size:

But the SAVESTAMP varies:
2017-12-13_14-35-19.03
2017-12-13_14-50-19.03
2017-12-13_14-55-48.94


thanks!
0
HI Experts

Could you advise what is the best way to source two property files inside windows batch file and use those property value in the batch script.

Scenario:
1. I have around 20 property/value in a file1.properties and file2.properties files. Assume file1 and file2 has 10 each...coming from two different source (Hope I can concat/append into one single file)
someprop1=somevalue1
someprop2=somevalue2
someprop3=somevalue3
.
.
someprop20=somevalue20

Open in new window


2. Have few batch files, where I would like to source above file1.properties & file2.properties (or merged single file) files inside these batch files and use those property value where ever required.
3. I'm used to to Linux way of source <file1.properties>. But looks like this is not possible in Window Batch? :)
4. In case file1.properties was populated with additional property/value dynamically. Instead of 10...it can have 15 in the future.

Could you help, what is the best way to achieve this please?
0
Hello all,

Using Borland C++ 4.52 on a Windows Virtual PC in XP Mode.

I am writing what I thought to be a pretty simple DOS program.  It is basically opening files, filling up structures, printing structure information to a file and that's it.  The files are binary and are less than 32 Kbytes, most are 1K or less.   I am 75% of the way done, it has been running fine up to now.  I just added some code to finish it off, and now I am getting this error at runtime:

"The NTDVM CPU has encountered an illegal instruction.
CS:00cc IP:0106 OP:ff ff 00 00 00 Choose 'Close' to terminate the application."

The thing is, the code I added is just a repeat of the same code that was at the beginning but to different structures.  Seems to have something to do with the code size?  I don't know.  I am not that familiar with memory management.  However, when I removed the stuff I had added, it works again.  

I am attaching both the main code and the extra code I am trying to add.

I would appreciate any guidance.
extracode.txt
main-code.txt
0
Hi Experts,
We have multipal windows system in network, in BOD process we need to copy some files in every systems manually, its a time taking process for me. Please suggest any bat (automatic) process to short out this trouble. Every systems having user name & password.
0
while repairing pc's i often boot from the windows 10 install USB stick into command prompt
questions :
1- what commands are available here?
2-can i change the keyboard layout to AZERTY ? if so - how?
0
Hello Experts,
how does make a bat file for continuous Ping multipal IP with background Colour changes ?
for example:-
start ping -t 192.168.207.11 -l 0
start ping -t 192.168.207.12 -l 0
start ping -t 192.168.207.13 -l 0
start ping -t 192.168.207.14 -l 0
start ping -t 192.168.207.15 -l 0
0
I have this old batch file that I used to upgrade a software and since it is time for another one I have tried creating a GPO and assigned it under User Configuration>Windows Settings>Logon.

But when testing with a user logging on the batch file wont run but when manually clicking the file it runs perfectly fine!

Here is the code:  xcopy "Source" "Destination" /S /C /I /H /R /Y

Users have a full time mapped drive from where the source file is copied to the local drive C:\Folder

Note that robocopy is the same and doesn't run automatically.
0
Get expert help—faster!
LVL 11
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

HI,


iam looking for a solution to count the files in folders & subfolders , calling for a path from the Main DIR.

The output will be Main folder name
(1) Primary folder  (Only name mostly)    (2) All the list of subfolders with count of files    (3) Only file extension.

This will include any empty folders

Also wish to know if any alternate tools which can copy large files in lesser time. ( From Dir to Dir). I have tried xcopy on Dos prompt even though it takes lot of time.
0
Hi Experts,

I have some tasks that currently users must do it manually in daily bases, however since this is prone to errors, the manager would like it should get automated done via code.

1- Look for specific file in default download folder that name starts with Tables_TodaysDate_LatestNumber.Zip (See attached).
2- Extract it to specific folder (C:\Application)
3- Delete old File C:\Application\Tables.MDB
4- Rename extracted file (something like Tables_2017-Oct-30_2230.mdb) to Tables.MDB

Would prefer it done either by calling some DOS commands from VBA or just using native VB functions if possible.

Thanks in advance.
Capture.PNG
0
I received an excellent response to my question of deleting files based on match and amount of days old.   Initially I was told they should delete based on age of file and if they have a matching .xxx file.    That has since changed to:   files should delete based on if there is a matching .xxx file and only if it is older than 3 days (regardless if the other files are older).  

The script help I received before from Bill Prew looks like:

@echo off
setlocal EnableDelayedExpansion

rem Define folder to process
set "BaseDir=C:\Users\ad9f2p\TEST CLEANUP"

rem Look at each .XXX file
for %%A IN ("%BaseDir%\*.xxx") do (

  rem Reset delete flag, and check all files with this same base filename
  set DeleteFlag=Y
  for %%B IN ("%BaseDir%\%%~nA.*") do (

    rem Get dyas since last modified (using VBS helper routine)
    set Fileage=0
    for /f "tokens=*" %%C in ('cscript //nologo fileage.vbs "%%~B"') do (
      set Fileage=%%C
    )

    rem If any file found less than 3 days old, do not delete the group
    if !FileAge! LEQ 3 (
      set DeleteFlag=N
    )
  )

  rem If all files found older than 3 days, delete them all
  if "!DeleteFlag!" EQU "Y" (
    ECHO del /q "%BaseDir%\%%~nA.*"
  )
)

Open in new window

Can I add a nested If statement to the section:

    rem If any file found less than 3 days old, do not delete the group
    if !FileAge! LEQ 3 (
      set DeleteFlag=N
    )

Open in new window

Can I check the file age on only the .xxx files and delete the corresponding files that match then, only if the .xxx file is older than 3 days?   I've tried doing this by rearranging the logic, currently it deletes everything with a .xxx file:    What am I missing here?


Open in new window

0
I'm trying to stream content using Livestreamer from YouTube to VLC. However, the streaming starts but the video is frozen. I notice no audio is present as well. Any ideas what It could be? I tried the smallest resolution 144p and I get the same results as if I try at 1080p.
0
Rename this sort of multiple file names
"20171014_user_id_17875988194160002_1507954651_replay.mp4"
to
"String1 user_id String2.mp4"

String user_id is dynamic in nature and not fixed and not known in advance
0
device driver not found BANANA
NO VALID CDROM device drivers selected

I had downloaded the ms dos 6.22 iso file and copy it into floppy by winimage but when I try to install ms dos it shows this error and in my system I don't have cdrom or dvdrom , I only have floppy drive with 500 mb hard disk.
0
Dear Experts,
We need codes for batch file to check a particular file is modify time is within last 30 Min.
If file is modified in last 30 Min then execute another batch file

Else end the script.

Requesting to help in the same.

Regards,
Girish T.
0
I will have several files during the day. Cannot select the latest with timestamp, i need to have to file with the greatest id.

The file name is in a format: [standardname]_[date]_[id].csv. Eg invoices_2017_09_19_186.csv
0
I need help. How to create batch file to import value from text file and write it to registery during osd.
I want to add key  in hkl\software\syswow64\me\  the value would be jack,  help would be appreciated.
thanks
0
NFR key for Veeam Backup for Microsoft Office 365
LVL 1
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Looking to use a dir command in the prompt that will write a txt file that includes the below info for ALL files:

File Name/ File Path / Last Modified Date/ Creation Date / Modified By

This should go through the entire subfolder structure of the directory.
0
Hi, We have a requirement as below

We  need a solution to extract the count of pages in a multipage TIFF file, which are available in Sub folders.

Thanks!
CPH
0
I would like a batch file to copy, lets say the word : magic.  After I double click on the batch file on my desktop, all I need to do is CTRL V anywhere for the word "magic" to be typed out.

Anyone knows how to do this?  Please assist.

Thank you !
0
I'm writing a batch file that needs to read In a text file with multiple lines (2-3 or more) and assign them to variables (i.e. Line1, Line2, Line3).  which will then act on those to run jobs based on the variables read in.  What is the easiest way to do this preferably without for loops or delims. etc.

Thx,
Brian
0
i want to create the Batch File to copy one file to another location & can i have complete list of  e.g /e /f /k or how to get this in cmd?

Thx..
0
We have a computer who is accessible by placing   '\\pc-name\j$'  in the Windows Explorer.  We also have that same location mapped using the command 'net use j: \\pc-name\j$'.

When in the command prompt we use   'Dir \\pc-name\j$'   or   'Dir J:\'   works excellently - total access.

However, if place   'J:\'   in the Windows Explorer or if we type   'start.', in order to open explorer at that point, it gives the following error:

WindowsExplorerLocationError



How can we successfully use Windows Explorer to access this   'J:\' ?
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.

Top Experts In
Microsoft DOS
<
Monthly
>