Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1151.

Solve : who knows to create a script to stop my tool.exe process when i get a type of er?

Answer»

who knows to create a script.bat  to stop my tool.exe process when i get a type of error 12 times in a row?
thank youCurious how your thinking of implementing this with batch. What will be used as a flag that an error happened 12 times. Do you have a log file that is created to where a batch can monitor this log file for 12 instances of an error and then perform a taskkill to tool.exe when 12 instances of some error MESSAGE is found?

Errorlevels might be able to be used if the error reports to command shell and upon error the program doesnt just hang at the error but times out and/or moves on so that you can get the 12 instances of an error maybe. http://www.robvanderwoude.com/errorlevel.php

More here on detecting problems with errorlevels http://stackoverflow.com/questions/13150676/using-errorlevel-in-a-batch-file-to-know-if-a-program-exited-normallyYou aren't learning anything having all these .bat files written for you...Just sayin... Quote from: patio on May 20, 2017, 08:22:03 AM

You aren't learning anything having all these .bat files written for you...Just sayin...

Interesting to view his posting history. Just sayin...
Hi 
If you know what is the exit code from your tool.exe, you can of course deal it with a batch file
Quote from: DaveLembke on May 20, 2017, 08:18:42 AM
Curious how your thinking of implementing this with batch. What will be used as a flag that an error happened 12 times. Do you have a log file that is created to where a batch can monitor this log file for 12 instances of an error and then perform a taskkill to tool.exe when 12 instances of some error message is found?

Errorlevels might be able to be used if the error reports to command shell and upon error the program doesnt just hang at the error but times out and/or moves on so that you can get the 12 instances of an error maybe. http://www.robvanderwoude.com/errorlevel.php

More here on detecting problems with errorlevels http://stackoverflow.com/questions/13150676/using-errorlevel-in-a-batch-file-to-know-if-a-program-exited-normally

i use AlwaysUP to schedule and run my tool.exe As system service,please take a look here ,u think is possible?
https://www.coretechnologies.com/products/AlwaysUp/Plugins/#CheckLogFileForError

this is the error code:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:
Dropping connection limit due to connection error to:

Now stop MyTool.exe when finds more then 10 errors in a row
Hi 
You can give a try for this script : Code: [Select]echo off
Mode con cols=80 lines=5 & color 9E
set "MyProcess=MyTool.exe"
Title Monitoring the process "%MyProcess%" for error by Hackoo 2017
Set "StopProcess=StopProcess.log"
Set "MyLogFile=Log.log"
Set "ErrorMsg=Dropping connection limit due to connection error to"
:MainLoop
cls
Set /a "ErrorLimit=10"
Set /a "Count=0"
For /f %%A in ('Type "%MyLogFile%" ^| find /I "%ErrorMsg%"') Do (
Set /a Count+=1
)
SET Count=00%Count%
SET Count=%Count:~-2%
echo(
echo                 Monitoring the process "%MyProcess%" for error
echo              The Counting of error message until now is = "%Count%"
echo        The ErrorLimit is set by the script = "%ErrorLimit%" for stopping this process
If "%Count%" GEQ "%ErrorLimit%" (
Goto KILLPROCESS
) else (
echo The counting of error = %Count% > "%StopProcess%"
Timeout /T 60 /Nobreak >nul
)
Goto MainLoop
::****************************************************************
:KILLPROCESS
echo The counting of error is reached to %Count% > "%StopProcess%"
Taskkill /IM "%MyProcess%" /F >> "%StopProcess%" 2>&1
Timeout /T 60 /Nobreak >nul & Goto MainLoop
Exit /b
::****************************************************************
A brief note about programming languages.

If the OP has a hard time with batch files, he might consider looking into an approach that makes things easier. There are a number of tools that have been created to make it easy to perform some kinds of update and maintain things  res on a PC.
Here are just a few better programming tools to save time and reduce unwanted errors. They all begin with the Letter P.

P#
Pearl
PHP
Pizza
PL/M
PostScript
Powershell
Prolog
Python

All the above have features that could make programming easier if you get STUCK with a batch file problem. Some experts  say you can not mix one language with another. I disagree, that is what I used to do years ago and I believe that kind of approach is still a good idea. Some experts  do not like it because it is not "Pure". Well, there is a language called "Pure" and it is tolerant.

[Pure is a small language designed from scratch; its INTERPRETER is not large, and the library modules are written in Pure.]

But even "Pure" will let you invoke other stuff if need be.

The pint I wish to make is the OP might consider looking around and trying to add to his skills. 

I will stop here. Just saying that the OP ought to do wider  study of programming. Looking at another language might help. 
Quote from: Geek-9pm on May 20, 2017, 10:18:31 PM
A brief note about programming languages.

If the OP has a hard time with batch files, he might consider looking into an approach that makes things easier. There are a number of tools that have been created to make it easy to perform some kinds of update and maintain things  res on a PC.
Here are just a few better programming tools to save time and reduce unwanted errors. They all begin with the Letter P.

P#
Pearl
PHP
Pizza
PL/M
PostScript
Powershell
Prolog
Python

All the above have features that could make programming easier if you get stuck with a batch file problem. Some experts  say you can not mix one language with another. I disagree, that is what I used to do years ago and I believe that kind of approach is still a good idea. Some experts  do not like it because it is not "Pure". Well, there is a language called "Pure" and it is tolerant.

[Pure is a small language designed from scratch; its interpreter is not large, and the library modules are written in Pure.]

But even "Pure" will let you invoke other stuff if need be.

The pint I wish to make is the OP might consider looking around and trying to add to his skills. 

I will stop here. Just saying that the OP ought to do wider  study of programming. Looking at another language might help. 

I use AlwaysUP to run my tool.exe and ... alwaysup have this option too can u help me config. please?
https://www.coretechnologies.com/products/AlwaysUp/Plugins/#CheckLogFileForError Quote from: Hackoo on May 20, 2017, 09:05:42 PM
Hi 
You can give a try for this script : Code: [Select]echo off
Mode con cols=80 lines=5 & color 9E
set "MyProcess=MyTool.exe"
Title Monitoring the process "%MyProcess%" for error by Hackoo 2017
Set "StopProcess=StopProcess.log"
Set "MyLogFile=Log.log"
Set "ErrorMsg=Dropping connection limit due to connection error to"
:MainLoop
cls
Set /a "ErrorLimit=10"
Set /a "Count=0"
For /f %%A in ('Type "%MyLogFile%" ^| find /I "%ErrorMsg%"') Do (
Set /a Count+=1
)
SET Count=00%Count%
SET Count=%Count:~-2%
echo(
echo                 Monitoring the process "%MyProcess%" for error
echo              The Counting of error message until now is = "%Count%"
echo        The ErrorLimit is set by the script = "%ErrorLimit%" for stopping this process
If "%Count%" GEQ "%ErrorLimit%" (
Goto KILLPROCESS
) else (
echo The counting of error = %Count% > "%StopProcess%"
Timeout /T 60 /Nobreak >nul
)
Goto MainLoop
::****************************************************************
:KILLPROCESS
echo The counting of error is reached to %Count% > "%StopProcess%"
Taskkill /IM "%MyProcess%" /F >> "%StopProcess%" 2>&1
Timeout /T 60 /Nobreak >nul & Goto MainLoop
Exit /b
::****************************************************************

ok thank you, i will try your script
Hackoo i use AlwaysUP scheduler to run my Tool.exe  As System and we have this option can u try to configure it please?take a look here
https://www.coretechnologies.com/products/AlwaysUp/Plugins/#CheckLogFileForErrorThere's no need to Quote all the replies to your posts...

Thank You.can u stop also cmd.exe and my tool.exe too?karlosss,
CMD.EXE is a part of Windows and is used to start batch files.
tool.exe is not identified as a standard item in Windows.
Some say that is the name used by malware.
Please explain where you got the tool.exe program, because we just can not guess what it is supported to do.

Here is just one of many links about tool.exe.
https://www.tenforums.com/software-apps/45148-software-reporter-tool-exe.html
So such a generic name makes for confusion.  i have a Script.bat who runs my tool.exe Quote from: karlosss on May 21, 2017, 12:03:58 PM
i have a Script.bat who runs my tool.exe
What is tool.exe?
If it is from a credulous PUBLISHER, it would have documentation that would help.
1152.

Solve : Use a special command to stop the application??

Answer» USE a SPECIAL COMMAND to stop the APPLICATION?
Its about AlwaysUP application and i use it to run other tools As System, i would like to STOP IT only when the Output.txt CONTENT finds the word  FINISHED.

http://imgur.com/a/4sy7f

1153.

Solve : Btch with exe parameter?

Answer»

Good morning

I'm making a batch file for windows, but I want it to receive several parameters and output the result to a file.

Is this the right way to write the batch file?

%1 %2 %3 %4 %5 %6 %7 %8 %9 > results.txt

where %1 is the exe? Doesn't seem to work very well when integrated within othe apps...

Regards

KeplerGenerally speaking, you have the right idea.  You can use %1, %2, etc... as parameters to a batch file and you can output the results to a file using the > direct the output.  There is a lot more to it than just those 2 aspects though, especially when you are interacting with an exe as you MENTIONED.  Often an exe will handle it's own output so invoking an exe from a batch file and attempting to redirect the output to a file will not work.

Can you give more specific examples of what you are trying to do? Quote from: kepler on June 03, 2017, 07:16:02 AM

Can you give more specific examples of what you are trying to do?

++1
shift
Quote from: strollin on June 03, 2017, 11:52:13 AM
Generally speaking, you have the right idea.  You can use %1, %2, etc... as parameters to a batch file and you can output the results to a file using the > direct the output.  There is a lot more to it than just those 2 aspects though, especially when you are interacting with an exe as you mentioned.  Often an exe will handle it's own output so invoking an exe from a batch file and attempting to redirect the output to a file will not work.

Can you give more specific examples of what you are trying to do?

Good day

I'm SORRY for the late reply. I wasn't able to check my email yesterday...

The idea is this: I want to create a batch file, that can call a executable (by means of a parameter) and its repectives parameters.

So, for instance, I would call;

mybatch.bat myexe.exe param1 param2

would run myexe.exe with the parameters 1 and 2 and send the output to a file (results.txt):

myexe.exe param1 param2 > results.txt

The exe would be a "parameter" to the batch, but to run.

Kind regards,

Kepler


Quote from: kepler on June 03, 2017, 11:19:05 PM
The idea is this: I want to create a batch file, that can call a executable (by means of a parameter) and its repectives parameters.

So, for instance, I would call;

mybatch.bat myexe.exe param1 param2

would run myexe.exe with the parameters 1 and 2 and send the output to a file (results.txt):

myexe.exe param1 param2 > results.txt

That might work, provided the exe was WRITTEN to accept command line parameters, and it writes text output to the console (to STDOUT if you want to get technical.) A QUICK question: why don't you just try it?
Hi

No, it wasn't working.... because the bat file was in utf8!!!... Jesus... I'm sorry for the trouble.

Have a nice weekend.

Kepler
1154.

Solve : Add prefix to existing file name using UNC path?

Answer»

I am trying to add a prefix to existing files within a UNC path. For some reason my code is changing the first character of the file name instead of appending it

Existing file names:
assignActivities-20170609100439.dat
assignActivities-20170609094939.dat

Desired file names:
SassignActivities-20170609100439.dat
SassignActivities-20170609094939.dat

Command:
REN \\server.com\hostfiles\Export\Semaphore\assignActivities-*.dat S*.dat

Resulting file names:
SssignActivities-20170609100439.dat
SssignActivities-20170609094939.datAre you sure? What OS are you using?
I don't understand.  Windows 7, command line but this will be running from SQL Server using CmdExec.

I'm told "REN" doesn't have an "insert" mode.

Someone suggested the following but it doesn't work in command line;
Code: [Select]LFNFOR On
FOR %v IN (`\\server.com\hostfiles\Export\Semaphore\assignActivities-*.dat`) DO REN %v prefix%v

'LFNFOR' is not recognized as an internal or EXTERNAL command,
operable program or batch file.OK. Sorry I do not use SQL  hardly ever.
I think this what you are using...
https://docs.microsoft.com/en-us/sql/ssms/agent/create-a-cmdexec-job-step
Quote

This topic describes how to create and define a Microsoft SQL Server Agent job step in SQL Server 2017 that uses an executable program or operating system command by using SQL Server Management STUDIO, Transact-SQL or SQL Server Management OBJECTS.

The rename command in Windows 7 CMD does not have an explicit insert  operator. But I think it allows you to rename a file with a longer name.

(For simplicity, I will not use paths and extensions in the EXAMPLES.)
Say I have wanted five files named:
ass0
ass456
ass4567
ass45678
Plus three  files a little different in the current directory
asw456
aws0
aqs456
I can use this to see of the first three letters identify the files I want
DIR äss* /b   
(Forum rules require me to use äas instead of *censored*.)
Yes, it shows only the five files, not the others.
Now I rename using
Code: [Select]REM äss* Sass*(Change ä to a in above.)
That will insert the letter S  at the start of each name.
Is that what you want?




1155.

Solve : Documentation for String Length?

Answer»

I was on SO and came across this post that asked how to break a string by delimiter and then count how many strings exist. The given answer(at the time) was this:

Code: [Select]echo off
SET "string=17.09.01.04.03"
set count=0
for %%a in (%string:.= %) do set /a count+=1
echo %count%
Is it DOCUMENTED anywhere that %string:.= % will break the string on the period?It won't break the string into sub strings but will only determine the count of the sub strings.Thanks the for quick reply 

Is there documentation somewhere that SAYS the code %string:.= % will provide the count? I'm just wondering how the PERSON who posted the answer was able to figure it out.See this:
http://www.dostips.com/DtTipsStringOperations.php#Snippets.Replace Quote from: QueenSvetlana on June 12, 2017, 11:10:44 AM

I'm just wondering how the person who posted the answer was able to figure it out.
It's just putting basic batch stuff together. They knew these things:

1. This is an example of batch string replacement: %string:.= % It means "the variable %string%, with each period (dot) changed to a space"

2. The replacement makes 17.09.01.04.03 become 17 09 01 04 03

3. A simple FOR command repeats once for each space-separated token

4. The variable %count% is set to 0 (zero) at the beginning.

5. Each time FOR repeats, the set /a count+=1 adds 1 (one) to the value of %count%

6. At the end, %count% is equal to the number of tokens.


1156.

Solve : Running old batch files on Win 10?

Answer»

Hard drive died. Got a new PC  with windows 10 installed. The previous batch FILE routine to compile C++ code WORKED fine on the old machine. Now they don't work. I get the "external internal command not recognized etc. error message. I assume Win 10 comes with a C++ compiler in Visual Studio  and there is a path statement in the bat file. Also I am familiar with changing the system path in the environment variables but I' :'(m not SURE what goes where. Has anyone else had this problem when changing over to wWin 10 Windows 10 doesn't come with Visual Studio or C++.Curious why you need to compile C++ from WITHIN a batch file. What IDE did you write your code in, you should be able to compile it there.... or do you have a batch file that dynamically generated the .cpp and then called to a command SHELL level compiler and then called to the EXE that is produced to execute it with dynamic info as part of the generated .cpp file?   

Interested in if you share your batch here what it actually does...I'd guess that it is effectively a makefile that is stored with the source code, and runs the cl compiler.He moght want to see th is:
https://www.visualstudio.com/vs/visual-studio-express/
Quote

Try out Visual Studio Community for a fully-featured and extensible IDE; An updated alternative to Visual Studio Express.
It incldues a C++ IDE.

Can you post the source code of your batch file and explain more what's your issues ?
Thank you !
1157.

Solve : How to get on videos folder with command line for any windows system ??

Answer»

Hi 
I'm making a new batch file to convert any *.mp4 files to *.mp3 files with VLC in command line, but i want to improve it to choose the Input folder on Videos for any windows system !
So, i wonder How to get on videos folder with command line ?
Thank you !

MP4-MP3_Converter.bat
Code: [Select]echo off
Title Convert (*.mp4) to (*.mp3) with VLC by (c) Hackoo 2017
mode con:cols=85 lines=5 & COLOR 0E
Taskkill /IM "vlc.exe" /F >nul 2>&1
echo.
set "VLC_URL=http://www.videolan.org/vlc/download-windows.html"

IF /I "%PROCESSOR_ARCHITECTURE%"=="x86" (
        Set "vlc=%ProgramFiles%\VideoLAN\VLC\vlc.exe"
    ) else (
        Set "vlc=%ProgramFiles(x86)%\VideoLAN\VLC\vlc.exe"
)

If Not Exist "%vlc%" (
    Cls & COLOR 0C
    echo.
    Echo       "The VLC program is not installed on your system"
    TIMEOUT /T 5 /NoBreak>nul
    Start "" %VLC_URL%
    Exit
)

Set "MP4Folder=C:\MP4Folder"
Set "MP3Folder=C:\MP3Folder"
If not exist "%MP3Folder%" MD "%MP3Folder%"
CD /D "%MP4Folder%"
for %%a in (*.mp4) do (
Cls
echo(
echo           Please wait a while ... The Conversion is in progress ...
echo   Conversion of "%%~na.mp4" to "%%~na.mp3"
"%vlc%" -I dummy "%%a" --sout=#transcode{acodec=mp3,ab=128,vcodec=dummy}:STD{access="file",mux="raw",dst="%MP3Folder%\%%~na.mp3"} vlc://quit
)
Explorer "%MP3Folder%" & ExitThe correct way of retrieving special folder locations is via SHGetSpecialFolderLocation or the Vista and later 'IKnownFolder' INTERFACE. The former should be possible with VBScript, as it is one of the features of Scripting.FileSystemObject. (GetSpecialFolder()).

You COULD hack it to get it working in batch, as there are some registry keys that contain this information. You can find them in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders. "My Video" would be the needed value.

There are a number of issues involved with using the key as noted here. It was effectively an early revision of how the special folders were stored dating back to the betas of Windows 95, but since it was documented and was being actively used by software, it was kept for release- and then more and more programs kept using it so we STILL have it all the way up through Win10. The limitations might not really apply for what you want to do though.

Speaking of the registry, VLC saves it's install location in the registry,  so you could retrieve that information that way too. It can be found in HKEY_LOCAL_MACHINE\SOFTWARE\VideoLAN\VLC (may need to also use the Wow6432Node to drill into the 32-bit registry)
Quote from: BC_Programmer on July 07, 2017, 08:01:23 PM

You COULD hack it to get it working in batch, as there are some registry keys that contain this information. You can find them in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders. "My Video" would be the needed value.
Thank you BC_Programmer, you put me on the right direction   
Code: [Select]echo off
Set "ShellFolderKey=HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
Set "MyKey=My Video"
For /f "tokens=4,* Delims= " %%A in ('Reg Query "%ShellFolderKey%" /v "%MyKey%" ^| Findstr /C:"%MyKey%"') Do (
echo "%%A"
)
pause
1158.

Solve : ctrl+c before process being killed??

Answer»

batch SCRIPT for windows OS, to press ''ctrl+c'' automatically  before process being killed?
If someone restarts the remote PC,pressing the keys ctrl+c  before process being killed this will save my WORK before pc shutting down
Is this a hacking script you want people to write for you?
You have learned nothing from the advice been given here in MONTHS...
It ALSO appears all you endeavors seem to be nefarious in nature.

Topic Closed.

Posting priviledges being reviewed.

patio.

1159.

Solve : ms dos 6.22 in dosbox problem?

Answer»

I have a problem with the virtual ms dos 6.2.2 install in the dosbox

Z:>mount d c:\622
Z:>d:
D:>imgmount 2 d1.img -size 512.63.16.142 -t HDD -fs none
D:>boot d1.img d2.img d2.img


start with welcome blue screen and wait enter
i press enter and new blue screen
must first configure HARD disk for use
i select configure first hard disk (recommended). enter
caution etc etc.....i press Y and.........Error
a disk error was detected while writing a new boot record to your
first hard drive...Press Enter to exit Setup......? ? ?


The three image files are ok and i have installed the ms dos 6.22 on a clean hard disk

Where is the problem ? ? ?




Was DOS 6.22 installed from an original set of disks or from an image downloaded off the net?My only question would be why the heck would you install DOS in dosbox ? ?

Just curious.
For what is is worth...
You can FIND Install DOS In Dosbox  on You Tube.
Installing MS-DOS 6.22 on DOSBox in Boot Mode
Who knows why.

1160.

Solve : Triple boot Dos,win xp,win7 help?

Answer»

Hi,
I'm desperate to find some help ... I have a laptop and wish to triple boot with dos, win xp and win 7.
Is there anyone who can guide me through? Also struggled to find a copy of dos 6.22
Any help much appreciated.
Ange
AngebigYiu can buy MS-DOS 6.22 install disk sets on eBay. Downloaded copies are not legal and this site will not help you get them. MS-DOS is not abandonware. AS for triple booting, you could look at grub4dos.


Other method of triple booting is having multiple drives installed, such as you can have each build on its own drive and after BIOS splash screen press F12 and then select which drive to boot from.

I USE to set up drives with dual-boot but it becomes a big mess when 1 of the builds gets trashed and needs to be reinstalled cleanly. So I myself install an OS to each drive in my desktop and then press F12 after BIOS splash screen and then select for which drive to boot from which I currently have Windows 7 and Windows 10 on my one system on 2 SEPARATE drives and default is boot to Windows 7, but if I need Windows 10, I can press F12 and select the other drive my non-SSD drive to boot from.

If you do go with the method of a triple boot on a single drive, I suggest cloning the drive when its finally configured properly for all operating systems or create an image of it so that you can quickly restore the drive back to clean working state if the drive is still healthy to take the image.

FreeDOS is an option if you want a OS that is almost EXACTLY like DOS and supports most of the DOS COMMANDS and software etc. http://www.freedos.org/    I have used this for when I need a specifically DOS OS, but dont want to have to connect my old USB/Floppy Drive or Connect an Internal Floppy Drive to install the OS to a drive. FreeDOS can also be installed to a bootable USB stick as well and you can boot off that USB stick and no have to mess with installing DOS internally to a drive.

*NOTE: Since you have a laptop likely limited to a single internal hard drive you could install XP and 7 to the hard drive and then FreeDOS to a USB stick and make for an easier build/setup. Additionally if you want something internal for a drive vs a USB stick hanging off the side of it if you have a MicroSD port you could also make a bootable MicroSD and boot FreeDOS off of that. I use my MicroSD port on my laptops as a convenient backup location for most important data in case the drive dies etc. But I have also used it for laptops without hard drives installed to run off of a 16GB MicroSD as if the MicroSD was a solid state drive, but slower than a SSD.With a laptop i dont think multiple HDD's is an option...For my Dell you can get an HDD holder that goes in the CD/DVD drive slot but that only GIVES you 1 more drive.

1161.

Solve : Batch file that generates lots of text?

Answer»

Hi,

I am working on a project in which I want a screen to show lots of TEXT being generated. A bit like that effect in the matrix.

I was thinking about making a of batch file to do some silly task in a loop like looking for a file in a folder and if its there rename it and then start looking for that file to rename it again, etc.

This works, but since it only generates 4 lines of text you kind of start to see the repetition, even though its much too fast to read.

Does anyone know some harmless task that I can put in a batch file to make it run more text?

Thank you!!

Hi 
Can you show us what did you tried as code until now ?
And explain more your AIM !Silly...

However...carry on...Hi,

I found SOMETHING that looks pretty good:

echo off
color 0a
:top
echo %random% %random% %random% %random% %random% %random%
goto top


I added this line that pings some fake IP address to make it go a little slower:

ping 10.109.199.199 -n 1 -w >nul

But now I'd like to be able to stop the flow of numbers when I hit a certain key and show some "text" like this:


  _     _            _    _         
 | |    | |          |  | |  |       
 | |__|  |   __   |  | |  |    ___ 
 |  __   |  / _ \  |  | |  |  /  _  \
 | |    | | |  __/ |  | |  | |  (_)  |
 |_|   |_|  \__   |_| |_|  \ ___/
                               
                               
does anyone know how to?


What you want used to be called "Tele Type Art".
Here is a Teletype machine:



And here is some Teletype Art:

Radio stations used to get this sort of thing at Christmas time.  Back in the days when Fax machines were not common. Somebody would spend hours making Art out of the letters of the Teletype.

Some more.....
http://taipeisignalarmy.blogspot.com/2010/09/teletype-art.html
and...
http://www.patorjk.com/software/taag/#p=display&f=Graffiti&t=Hello%20Folks.%0A

Hi 
Just give a try for this batch file  ( Matrix Animation with DJ Buzz Radio ) in the attachments and tell me the result   


[attachment deleted by admin to conserve space]Source code of Matrix Animation + DJ Buzz Radio

Code: [Select]echo off
Title Matrix Animation with DJ Buzz Radio by Hackoo 2017
mode con cols=64 lines=35 & color 0A
echo(
echo       Please wait a while ... DJ Buzz Radio is loading ...
Call :Play_DJ_Buzz_Radio
cls
:Matrix
echo  %random% %random%  Hackoo %random% %random% %random% %random% %random% %random% %random% %random%
echo  %random%   %random% %random% %random%    %random%   %random% %random% %random%   %random%
echo %random%   %random% %random% %random%  Hackoo  %random%   %random% %random% %random%   %random%
echo  %random%   %random%%random% %random%    %random%   %random% %random% %random%   %random%
echo  Hackoo   %random%  %random%   %random% %random%   %random%  %random% %random% %random%   %random%
echo  %random%    %random%   %random% %random% %random%    %random%  %random% %random% %random% %random%
echo %random%   %random%   %random% %random%    %random%     %random% %random% %random%
echo  %random%   %random%   %random% %random%    %random%   %random% %random% %random%   %random%
echo  %random%  %random% %random% %random% %random% %random% %random% %random%  %random%
echo  %random%    %random%   %random% %random% %random%    %random%   %random% %random% %random% %random%
echo %random%   %random% %random% %random%  Hackoo  %random%   %random% %random% %random%   %random%
echo  %random%   %random% %random% %random%    %random%   %random% %random% %random%   %random%
echo    %random%  %random%   %random% %random%    %random%    %random% %random% %random%   %random%
echo   %random%   %random%   %random% %random% %random%    %random%  %random% %random% %random% %random%
echo %random%   %random%   %random%%random%  Hackoo  %random%     %random%     %random% %random%
echo  %random%   %random%   %random% %random%    %random%   %random% %random% %random% %random%
echo   %random%   %random%    %random% %random% %random% %random% %random% %random% %random% %random%
echo  %random%   %random% %random% %random%    %random%   %random% %random% %random%   %random%
echo %random%   %random% %random% %random%  Hackoo %random%   %random% %random% %random%  %random%
echo  %random%   %random% %random% %random%    %random%   %random% %random% %random% %random%
echo    %random%  %random%   %random% %random%    %random%     %random% %random% %random%  %random%
echo  %random% Hackoo   %random%   %random% %random% %random%    %random%  %random% %random% %random% %random%
echo %random%   %random%   %random% %random%    %random%  Hackoo   %random%     %random% %random%
echo  %random%   %random%   %random% %random%  %random%  %random%   %random% %random% %random% %random%
set /a Counter+=1
if "%Counter%" EQU "200" goto End_Animation
ping 10.109.199.199 -n 1 -w >nul
goto Matrix
::************************************************************************
:End_Animation
cls
echo(
echo Press enter button to continue .....
runas /user:# "" >nul 2>&1
cls
:::
:::      __   __  _______  ___      ___      _______
:::     |  | |  ||       ||   |    |   |    |       |
:::     |  |_|  ||    ___||   |    |   |    |   _   |
:::     |       ||   |___ |   |    |   |    |  | |  |
:::     |       ||    ___||   |___ |   |___ |  |_|  |
:::     |   _   ||   |___ |       ||       ||       |
:::     |__| |__||_______||_______||_______||_______|
:::
:::              _ _,---._
:::           ,-','       `-.___
:::          /-;'               `._
:::         /\/          ._   _,'o \
:::        ( /\       _,--'\,','"`. )
:::         |\      ,'o     \'    //\
:::         |      \        /   ,--'""`-.
:::         :       \_    _/ ,-'         `-._
:::          \        `--'  /                )
:::           `.  \`._    ,'     ________,','
:::             .--`     ,'  ,--` __\___,;'
:::              \`.,-- ,' ,`_)--'  /`.,'
:::               \( ;  | | )      (`-/
:::                 `--'| |)       |-/
:::                   | | |        | |
:::                   | | |,.,-.   | |_
:::                   | `./ /   )---`  )
:::                  _|  /    ,',   ,-'
:::                 ,'|_(    /-<._,' |--,
:::                 |    `--'---.     \/ \
:::                 |          / \    /\  \
:::               ,-^---._     |  \  /  \  \
:::            ,-'        \----'   \/    \--`.
:::           /            \              \   \
:::

for /f "delims=: tokens=*" %%A in ('findstr /b ::: "%~f0"') do echo(%%A
echo         Press any key to stop the DJ Buzz Radio
pause>nul & Call :Stop_Radio & exit
::**************************************************************
:Play_DJ_Buzz_Radio
Taskkill /IM "wscript.exe" /F >nul 2>&1
Set vbsfile=%temp%\DJBuzzRadio.vbs
Set "URL=http://www.chocradios.ch/djbuzzradio_windows.mp3.asx"
Call:Play %URL% %vbsfile%
Start %vbsfile%
Exit /b
::**************************************************************
:Play
(
echo Play "%~1"
echo Sub Play(URL^)
echo Dim Sound
echo Set Sound = CreateObject("WMPlayer.OCX"^)
echo Sound.URL = URL
echo Sound.settings.volume = 100
echo Sound.Controls.play
echo do while Sound.currentmedia.duration = 0
echo wscript.sleep 100
echo loop
echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000
echo End Sub
)>%~2
exit /b
::**************************************************************
:Stop_Radio
Taskkill /IM "wscript.exe" /F >nul 2>&1
::**************************************************************

1162.

Solve : Using vaiables in a path?

Answer»

Hey guys,

I'm STARTING to code in DOS and I am having some troubles with the use of variables. I wrote a code to ROBOCOPY a given file to a disk of my choosing using a variable. Here's a shortened version of my code:

set backupdisk=G:
robocopy c:\users\... %backupdisk%\documents\backups /E /copyall

Every time I run it, the command prompt interprets it with a space between the variable and the rest of the path (%backupdisk% \documents\backups) so it never works,

Does someone know what's wrong with my code? Thanks!It doesn'tt do that on my system.

Code: [Select]echo off
set backupdisk=G:
echo robocopy c:\users\... %backupdisk%\documents\backups /E /copyall
Code: [Select]robocopy c:\users\... G:\documents\backups /E /copyall The space is a real character and the set statement takes everything literally. Open your code in an editor and check for a trailing space on the set statement.

Sometimes it's the SIMPLE things,

SidewinderYes. I am so used to my editor (Scite) removing trailing white space when saving I forgot it was possible. I TRIED it with Notepad and got the space in the variable.
Hi 
I CREATED this batch script for incremental and scheduled backup using xcopy command in batch.
The first execution of this script is to configure the paths of the source and the destination. And saves them in a .cfg file and then makes a full copy for the first time.

It creates a scheduled task to run every hour with an incremental copy (ie : only copies the new FILES or has been modified from the source).

Incemental Backup.bat

1163.

Solve : this program cannot be run in dos mode?

Answer»

Okay so i'm trying to USE attrib.exe in ms dos but it says "this program cannot be run in dos mode".

I THOUGHT attrib was supported as an external COMMAND. Anyone have an IDEA on why it isn't working?  "This program cannot be run in DOS Mode" is the error message a 32-bit Windows executable gives when you try to run it in MS-DOS. Based on that I think your attrib.exe is from a Windows installation as is not a DOS Executable, so you cannot use it there.Thank you for replying. But how would I get a 16 bit version of attrib? Quote from: ChickenJoe on August 19, 2017, 12:48:52 PM

Thank you for replying. But how would I get a 16 bit version of attrib?
From the MS-DOS install disk set. It's on Disk 1 I think.


Correct...
1164.

Solve : vbr(volume boot record) to floppy disk?

Answer»
The ms dos boot DISK can be created by creating a volume boot record in the volume boot sector of the disk. This automatically makes some program in windows or cmd, dos shell with format / s or sys command.
My question is ..... i could create vbr with hex \ disk editor and with ASSEMBLER maybe ......?

It is not clear what you need to do.
Is this for educational uses?
Is this needed for a useful project?
MS-DOS has been retired for some TIME and  is not often used for any new application.

When people come here with MS-DOS questions is is often about maintenance to an OLD system that must be kept running. If you are USING a computer that needs a boot floppy disks that can boot, the process is done at the time you format the floppy.

First you have to boot up with a floppy that already has both the system and the needed utilities. You insert a new or old floppy in the B: drive and issue a command to format and systematize the floppy in the second drive.
format b: /s
The will write the needed data into the proper place on the floppy.
Is that what you wanted to know?


1165.

Solve : one disk drive?

Answer»

How to write commands to MS dos when it has one disk drive on the computer
For example if i want to run scandisk and check another floppy then what i write?

So this computer only has a single floppy drive and no hard drive?If i have ms dos on bootable floppy disk 1.44 and load system of this how i can work in another floppy disk ?
for example     a:\>  and i want copy file or scandisk in floppy without ms-dos ?
Under MS-DOS since v5,  in a 2 floppy drive system, the drives are A: and B:, if there is only one floppy drive it will be A: at boot, but if you specify B:, the system will prompt you to insert another floppy disk and will consider itself logged in to that drive letter (SHOW that letter at the prompt etc) until you switch back again.

Quote

MS-DOS/PC DOS since version 5.0, and later operating systems, assigns drive letters according to the following algorithm:

Assign the drive letter A: to the first floppy disk drive (drive 0), and B: to the second floppy disk drive (drive 1). If only one physical floppy is present, drive B: will be assigned to a phantom floppy drive mapped to the same physical drive and dynamically assigned to either A: or B: for easier floppy file operations.


You can't do what you want with only 1 drive...period. Quote from: patio on August 24, 2017, 01:04:33 PM
You can't do what you want with only 1 drive...period.
Are you sure?
A RAMDrive could be created and scandisk copied to that if it fits within the limited size of the RAM Drive. This allocates a section of RAM to act as a virtual hard drive. You can then scan disk the next disk in the drive from say the RAMDisk drive of E: So from E: you would run scandisk A: or with whichever switches you want to use with it for disks placed into A:

https://books.google.com/books?id=u7oN-5y7nGsC&pg=PA175&lpg=PA175&dq=ramdrive.sys+dos&source=bl&ots=j6i62HQrs-&sig=flW8BOAJYi7Kc36RcrqXlSDNN9o&hl=en&sa=X&ved=0ahUKEwjn-s_g0vDVAhXG7YMKHUUwBHgQ6AEIUjAH#v=onepage&q=ramdrive.sys%20dos&f=false


You need a bootable floppy with DOS 6.22, then configure it for the RAMDRIVE to be active at next boot. Reboot computer and RAM Drive is created. Next copy scandisk to the RAM Drive such as at letter E: and then remove the bootable floppy from A: and insert the disk you want to scan into the drive at A: and from E: run scandisk with whatever switches if any and A:


*Is this a homework project?

In regards to what salmon said... I do recall many years ago being able to call to a single drive at both A: and B: and it read the disk and I never understood why. I thought that it was messed up somehow since only 1 drive was present. Curious how the A: to B: method would work in a single drive system since the disk removed would take scandisk away with it. RAMDrive is only method I can think of to make this work with scandisk remaining in RAM to be called.  Quote from: Salmon Trout on August 24, 2017, 01:10:08 PM
Are you sure?

He never stated 2 drives...so i'll stick to what i stated...unless we get the full story...Salmon Trout's method works. I wasn't familiar with it so I just gave it a shot in VMWare under MS-DOS 6.22.

The VM I have only has one floppy drive. I was able to use chkdsk on a bootable floppy image and run it against a separate image that had only data files using the "Phantom drive" approach.

A simple "scandisk B:" when A: is the current drive seemed to do the trick. It PROMPTED for the disk for B:, and I swapped in the data diskette.

LKooks like you can also change to the data diskette directly via B: and then run A:\scandisk B: and it prompts for the A: diskette, then the B: Diskette, and the program runs against B:.I can still remember when I upgraded my Epson Equity II XT PC from MS-DOS version v3.3 to v5.0, thanks to a pal who had a spare set of 5.25" floppies. QBasic! the editor! And of course the phantom floppy thing I mentioned above. It had one 5.25" 360K floppy drive. You could run WordPerfect off A: and keep your documents on B: , and the system told you when to swap the disks.

Quote from: BC_Programmer on August 24, 2017, 03:07:35 PM
Salmon Trout's method works. I wasn't familiar with it so I just gave it a shot in VMWare under MS-DOS 6.22.

The VM I have only has one floppy drive. I was able to use chkdsk on a bootable floppy image and run it against a separate image that had only data files using the "Phantom drive" approach.

A simple "scandisk B:" when A: is the current drive seemed to do the trick. It prompted for the disk for B:, and I swapped in the data diskette.

LKooks like you can also change to the data diskette directly via B: and then run A:\scandisk B: and it prompts for the A: diskette, then the B: Diskette, and the program runs against B:.


!!!!!!!!!!!!!!!!!
Very Cool on the A: (Phantom B:) approach. Easier than a RAMDrive and your method supports older DOS than 6.22 also.
1166.

Solve : How to count the underscore in a filename variable ??

Answer»

Hi 
I have this script in ORDER to count the underscore in a file name variable!
but, I have always the count is equal to zero?
What wrong with this script?
Code: [Select]echo off
set /a "cnt=0"
set /a "pos=0"
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('Dir /b "%userprofile%\Desktop"') do (
set "filename=%%a"
Call:Stringloop "!filename!"
)

pause & exit
::**************************************************
:Stringloop <filename>
set "filename=%~1"
if "!filename:~%pos%,1!"=="_" set /a cnt+=1
set /a pos+=1
if not "!filename:~%pos%,1!"=="" goto Stringloop
echo !filename! : !cnt!
exit /b
::*************************************************Thank you !Cant test this from work where I am now, but say you place X in for underscore _ and have filename as Xmen.doc does it then show counter equal to 1 and a file name as Xfiles.TXT as a value of 3 since it gets two more X's from that file too? This tests the core of what you have so you know the only issue is "_"

Wondering if an escape character is needed for the underscore to be detected as such if thats the case. Or other method is testing for specific ASCII value for each character in filenames vs character match. https://helloacm.com/the-chr-function-implementation-in-windows-pure-batch-script/

"^_"   this might be the fix if its just requiring an escape character. 

http://www.robvanderwoude.com/escapechars.php

btw the ascii decimal identifier for underscore is 95 so such as if you press and hold alt and then type 95 on keypad and then release alt you will get an underscore in notepad etc. You can test through chr and test that way for 95 vs  for "_" and that might fix this. Escape character if thats the fix is the easiest fix though.

This might be a fixed version... UNABLE to test on work computer though 
Code: [Select]echo off
set /a "cnt=0"
set /a "pos=0"
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('Dir /b "%userprofile%\Desktop"') do (
set "filename=%%a"
Call:Stringloop "!filename!"
)

pause & exit
::**************************************************
:Stringloop <filename>
set "filename=%~1"
if "!filename:~%pos%,1!"=="^_" set /a cnt+=1
set /a pos+=1
if not "!filename:~%pos%,1!"=="" goto Stringloop
echo !filename! : !cnt!
exit /b
::*************************************************2 points, one RED, one green (see code)

(1) You need to set pos=0 for each file name. Your script sets it once and it just increases forever. No need to do set /a when creating a variable, only when you do arithmetic on it.

(2) To get a variable to work in a substring expression you need to use CALL SET (to make a child process expand the variable - and you need to double up the percent signs as shown)

echo off
set cnt=0
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('Dir /b "%userprofile%\Desktop"') do (
   
   REM (1)
   set pos=0
   

   set "filename=%%a"
   Call:Stringloop "!filename!"
)
pause & exit
::**************************************************
:Stringloop <filename>
set "filename=%~1"

REM (2)
CALL Set "char=%%filename:~%pos%,1%%"


if "!char!"=="_" set /a cnt+=1
if "!char!"=="" echo !filename! : !cnt! & exit /b
set /a pos+=1
goto Stringloop
::*************************************************

Output...


HP : 0
iPlayer Recordings : 0
LockScreen Images by Winaero Tweaker : 0
Tor Browser : 0
Tor Browser2 : 0
Burn to the Brim.lnk : 0
Core Temp Gadget & Addons.url : 0
Core Temp.lnk : 0
desktop.ini : 0
Folder Size Explorer.lnk : 0
Folder Size.lnk : 0
FreeCommander XE.lnk : 0
Frhed.lnk : 0
Google Chrome Canary.lnk : 0
grub-choose-default.lnk : 0
HandBrake.lnk : 0
Intel© Power Gadget 3.0.lnk : 0
Internet Explorer.lnk : 0
MTPuTTY.lnk : 0
Namexif.lnk : 0
New_Text_Document_01.txt : 3
New_Text_Document_02.txt : 6
New_Text_Document_03.txt : 9
New_Text_Document_04.txt : 12
New_Text_Document_05.txt : 15
New_Text_Document_06.txt : 18
New_Text_Document_07.txt : 21
New_Text_Document_08.txt : 24
Nmap - Zenmap GUI.lnk : 24
NTLite.lnk : 24
Opera browser.lnk : 24
OSFMount.lnk : 24
ParNRar.lnk : 24
Perspective_Image_Correction.lnk : 26
Process Hacker 2.lnk : 26
QExplore 'My Computer'.lnk : 26
RapidBATCH 5.1 Personal Edition.lnk : 26
RMCDesigner.lnk : 26
RMPrepUSB.lnk : 26
SABnzbd.lnk : 26
Start Tor Browser.lnk : 26
Subtitle Edit.lnk : 26
Transmission Remote GUI.lnk : 26
VcXsrv.lnk : 26
Windows 10 Upgrade Assistant.lnk : 26
Windows 7 USB DVD Download Tool.lnk : 26
XLaunch.lnk : 26
Zipware.lnk : 26
Press any key to continue . . .

Thank you, both for your reply!
Salmon Trout
Your script works but, I want to get for every file the count of its underscore!
for example in your output you get SOMETHING like that on this file : New_Text_Document_08.txt : 24
or we expect like this : New_Text_Document_08.txt : 3  and so on ......
Edit
I got it 
The mistake: The variables cnt and pos are never reset to 0
so to correct this we should do like this :
Code: [Select]echo off
Rem The srting to count in the filename is the underscrore "_"
Rem we can of course set another one ;)
set "MyString=_"
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('Dir /b "%userprofile%\Desktop"') do (
   set "filename=%%a"
   set /a "cnt=0"
   set /a "pos=0"
   Call:Counting_String "!filename!" "%Mystring%"
)
pause & exit
::*********************************************************
:Counting_String <filename> <MyString>
set "filename=%~1"
set "string=%~2"
if /I "!filename:~%pos%,1!"=="%Mystring%" set /a cnt+=1
set /a pos+=1
if not "!filename:~%pos%,1!"=="" goto Counting_String
echo !filename!: [!cnt!] "%Mystring%"
exit /b
::********************************************************* Quote from: Hackoo on August 28, 2017, 06:54:48 PM

Thank you, both for your reply!
Salmon Trout
Your script works but, I want to get for every file the count of its underscore!
for example in your output you got something like that on this file : New_Text_Document_08.txt : 24
or we expect like this : New_Text_Document_08.txt : 3  and so on ......
Edit
I got it 
The mistake: The variables cnt and pos are never reset to 0
so to correct this we should do like this :
Code: [Select]echo off
Rem The srting to count in the filename is the underscrore "_"
Rem we can of course set another one ;)
set "MyString=_"
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('Dir /b "%userprofile%\Desktop"') do (
   set "filename=%%a"
   set /a "cnt=0"
   set /a "pos=0"
   Call:Counting_String "!filename!" "%Mystring%"
)
pause & exit
::*********************************************************
:Counting_String <filename> <MyString>
set "filename=%~1"
set "string=%~2"
if /I "!filename:~%pos%,1!"=="%Mystring%" set /a cnt+=1
set /a pos+=1
if not "!filename:~%pos%,1!"=="" goto Counting_String
echo !filename!: [!cnt!] "%Mystring%"
exit /b
::*********************************************************
You completely missed the fancy way aGerman showed you how to accomplish your task.  His code has no GOTO commands so it literally counts it all in one pass.
http://www.dostips.com/forum/viewtopic.php?f=3&t=8071#p53604 Quote
aGerman showed you how to accomplish your task

 

Knows its praise, but ( a German ) just has a strange tone to its label. Not sure if its because I'm half German myself etc and had issues with people years ago in elementary school jabbing at my ancestry etc when sharing family tree info etc. Knows its praise and not a bad label etc. Thinking stating Salmon Trout would have been sufficient. Maybe Salmon Trout and Squashman are at some joking around level that makes this less odd in reading.    But concerned that passer bys might FIND that not so much a praise and maybe offensive.  Just my thoughts. While not jewish, family members ( my great grandfathers brothers and sisters ) died trying to escape the war, 2 of which when pressured to join the nazi army left the world on their own terms vs joining as a nicer way of explaining a bad situation as to how they died. I am not offended by squashman... all is cool but just my concerns about passerbys who might not understand a friendship joking jingle with that label.  The aGerman thing is a mystery to me. I think maybe that is the username of someone on the dostips forum, that is linked to in squash man's reply.OHHHHHHHHHHHHHHHHHHHHHHHHHHHHhhhhhhhhhh hhhhhhhhhhh 

I was thinking it was cause you were German and you ended up helping him. Just went to dostips and sure enough there is a username of aGerman... well now passer bys wont be confused and accidentally offended with what may be looked at as a label vs a username.  I saw it as a typo missed space and ( a German ) basically. Laughing at myself in not seeing the connection of aGerman with a username and going in the wrong direction. I'm not German, I'm English! 

All these years I thought you were German when referring to europe and seeing this.

Quote
Völlig losgelöst   
von der Erde   
schwebt das Raumschiff   
völlig schwerelos.

Oh that! It's some words of a song, "Major Tom (Coming Home)" by Peter Schilling (who is German!) It was the theme tune of a German TV series called "Deutschland 83", a spy drama set in 1983. I really liked it. The song was a big European hit in that year. So was the TV series in 2015. I just thought it was cool to put some of the words in my signature. The series premiered on 17 June 2015 on the SundanceTV channel in the United States, becoming the first German-language series to air on a US network.COOL and now it all makes sense  Glad we got that all cleared up.  For many years I thought my ancestors were from Germany but it turned out they were actually from Austria but they spoke German.
1167.

Solve : Copy files toa folder, add suffix to prevent overwrite.?

Answer»

I have seen it done. Somehow there is a way of putting files in one folder and ADDING a number to the end of the NAME to prevent overwrite. But how do I tell a copy utility to do that? Or is there a special utility that will do that?

Example:
I search for files with a string. I find a lot with the same name. I want to copy them to a USB flash and do some more searching on the files. So,  has to be be a way to add a number suffix to prevent overwrite.
How can it be done? 
Windows 7 onwards can automatically add suffix numbers when you paste a file or files into a folder where the same file name exists. I mean using Windows Explorer.
Hi 
You don't provide any code, so here is a startup code for you to test and modify it for your puropse  : How to Copy (and increment) Multiple Instances of a File Using Batch File Thank you both. That was helpful.

In Windows 7 or 10, if you are using Windows Explorer, try copying a test file from one folder and pasting into another empty folder. Then go back and do it again. When you click 'paste' the second time you will be offered 3 choices -

(1) Replace destination file (overwrites file that is already there)
(2) Skip copying (copies nothing, leaves alone file that is already there)


(3) Compare both files; you can then replace, skip or rename the newer file with a number

If you already have just New Text Document.txt, the next time you pasted a file with that same name, in the same folder, it will be pasted as New Text Document (2).txt

Try to paste in same folder, choose 3rd option:


Check both boxes:


Newer file is renamed:


This is how it looks in Windows 10, but Windows 7 is very similar. if you are doing lots of files, they will be renumbered consecutively.




Thanks,
The GRAPHICAL way is much easier that trying to make a batch script.
I think I saw somersetting like that before, but I con not remember how. 
Hi 
I made for this batch script to copy with incrementaion
Copy_TXT_Files.bat
Code: [Select]echo off
::***********************************************************************************
Mode con cols=80 lines=5 & color 9E
Title Searching for a connected USB drive .....
:Find_USB_Drive
for /f "tokens=2" %%i in ('wmic logicaldisk where "drivetype=2" ^|find /i ":"') do (Set MyUSB=%%i)
cls
setlocal ENABLEDELAYEDEXPANSION
set _drive=%MyUSB%
If Exist !_drive! (
cls
echo           #########################################################
echo                        Your usb key is connected as !_drive!
echo           #########################################################
echo Press any key for copying files on this drive !_drive!
pause>nul & goto Main
) ELSE (
cls
color 0C
echo.
echo           #########################################################
echo                         Your usb key is not detected
echo           #########################################################
echo.
pause>nul & exit
)
::***********************************************************************************
:Main
set "Pattern=*.txt"
Mode con cols=90 lines=5 & color 9E
Set "LOCATION=%userprofile%\Desktop"
Set "Ext=TXT"
Set "Destination=!_drive!\Copy_%EXT%_Files"
Title Searching for "%Pattern%" files paths and copy them to "%Destination%
set "LogSearch=%~dp0%~n0.txt"
Set "CopyLog=%~dp0%~n0_CopyLog.txt"
If exist "%CopyLog%" Del "%CopyLog%"
Set Count=1
If exist "%LogSearch%" Del "%LogSearch%"
Cls
echo(
echo       --------------------------------------------------------------------------
echo              Please Wait a while ....... Searching is in progress .........
echo       --------------------------------------------------------------------------
   Where /R %Location% "%Pattern%" /F >>"%LogSearch%" 2>&1

If "%ErrorLevel%" EQU "1" (
Cls
echo(
echo       --------------------------------------------------------------------------
echo                         No file(s^) found with this Pattern
echo       --------------------------------------------------------------------------
)

If "%ErrorLevel%" EQU "0" (
If Not exist "%Destination%" MD "%Destination%"
Setlocal enableDelayedExpansion
for /f "delims=" %%a in ('Type "%LogSearch%"') do (
If not exist "%Destination%\%%~nxa" (
echo copying file %%a >> %CopyLog% 2>&1
Copy "%%~a" "%Destination%" >> %CopyLog% 2>&1
) else (
Call :Increment_Copy "%%~a" "%Destination%"
)
)
)
Start "" "%LogSearch%"
Start "" "%CopyLog%"
If exist "%Destination%" Explorer "%Destination%"
exit
::**************************************************************************
:Increment_Copy <source> <Destination>
set "Source=%~1"
set "Destination=%~2"
set "Filename=%~n1"
if exist "%Destination%\%Filename%(%Count%)%~x1" set /a Count+=1 && goto Increment_Copy
echo "%Source%" "%Destination%\%Filename%(%Count%)%~x1" >> %CopyLog% 2>&1
copy "%Source%" "%Destination%\%Filename%(%Count%)%~x1" >> %CopyLog% 2>&1
set /a Count=1
exit /b
::**************************************************************************Hi 
Here is another improved version for Incremental_Copy.bat : This script can search for any batch script *.bat located on your hard drive C:\ and copy them with incrementation, ie (To avoid overwritten copy) in other location that you can fix it by the script for example,  i choose E:\
If you want for example to backup all your *.vbs files, just change this variable set "Ext=VBS"
Code: [Select]echo off
Mode con cols=90 lines=5 & color 9E
set "Ext=BAT"
set "Pattern=*.%Ext%"
Set "Source=C:\"
Set "Destination=E:\Backup_Copy_%Ext%"
Title Searching for "%Pattern%" files paths and copy them to "%Destination%" by Hackoo 2017
set "LogSearch=%~dp0%~n0_SearchLog_%Ext%.txt"
Set "CopyLog=%~dp0%~n0_CopyLog_%Ext%.txt"
If exist "%CopyLog%" Del "%CopyLog%"
If exist "%LogSearch%" Del "%LogSearch%"
Cls
echo(
echo       --------------------------------------------------------------------------
echo              Please Wait a while ....... Searching is in progress .........
echo       --------------------------------------------------------------------------
   Where /R %Source% "%Pattern%" /F >>"%LogSearch%" 2>&1
If "%ErrorLevel%" EQU "1" (
Cls
echo(
echo       --------------------------------------------------------------------------
echo                         No file(s^) found with this Pattern
echo       --------------------------------------------------------------------------
)

If "%ErrorLevel%" EQU "0" (
If Not exist "%Destination%" MD "%Destination%"
Setlocal enableDelayedExpansion
for /f "delims=" %%a in ('Type "%LogSearch%"') do (
Call :Incremental_Copy "%%~a" "%Destination%" "%CopyLog%"
)
)
Start "" "%LogSearch%"
Start "" "%CopyLog%"
If exist "%Destination%" Explorer "%Destination%"
exit
::**************************************************************************
:Incremental_Copy <Source> <Destination> <CopyLog>
set "Source=%~1"
set "Destination=%~2"
set "Filename=%~n1"
Set "CopyLog=%~3"
If Not Exist "%Destination%\%~nx1" (
Cls
echo(
echo       --------------------------------------------------------------------------
echo               Copying to "%Destination%\%~nx1" . . .
echo       --------------------------------------------------------------------------
(
echo Copying "%Source%" "%Destination%\%~nx1"
Copy /DVN "%Source%" "%Destination%\%~nx1"
) >> "%CopyLog%" 2>&1
) else (
If Exist "%Destination%\%Filename%(%Count%)%~x1" Set /a Count+=1 && goto Incremental_Copy
Cls
echo(
echo       --------------------------------------------------------------------------
echo               Copying to "%Destination%\%Filename%(%Count%)%~x1" . . .
echo       --------------------------------------------------------------------------
(
echo Copying "%Source%" "%Destination%\%Filename%(%Count%)%~x1"
copy /DVN "%Source%" "%Destination%\%Filename%(%Count%)%~x1"
)>> "%CopyLog%" 2>&1
Set /a "Count=1"
)
exit /b
::**************************************************************************NB : Just change the Ext and and the drive of your destination variables Hackoo, Thanks. 
Quote from: Geek-9pm on August 08, 2017, 09:20:04 AM

Hackoo, Thanks. 
Geek-9pm You are welcome 
Don't forget the link to thank me 
+
Hackoo !Anyone who begs for thanx doesn't deserve them.Beggars can't be choosers. 
Quote
...widely held medieval opinion that if you asked for and received a gift you should be grateful for it. The 'gift horse' proverb was recorded first, in Heywood's 1546 version of A dialogue conteinyng the nomber in effect of all the prouerbes in the Englishe tongue.

'Beggars should not be choosers' didn't appear until the 1562 version of 'Proverbs'.

    Beggers should be no choosers, but yet they will:
    Who can bryng a begger from choyse to begge still?
http://www.phrases.org.uk/meanings/beggars-cant-be-choosers.html Quote from: patio on August 08, 2017, 04:41:17 PM
Anyone who begs for thanx doesn't deserve them.

And did you think this really in my case ? i spend my time to WRITE a special code over the night to help him to achieve his aim, and you post me something that discourage me
Thank you  for your nice reply and for your encouragementYou've been thanked for contributions...i was stating asking is a bit of a reach.

But if thats what's important...go for it.I did thank.
1168.

Solve : Rename files from a string in random places from a text file?

Answer»

I am trying to rename a bunch of .m3u files based on the text between ", and (s. The text might contain characters INCLUDING Code: [Select]& (random text) . : ! | -
So I need to remove the colon and the pipe. There is also white space before and after that I'd like to remove.

Here are two examples

in channel1.m3u

Code: [Select]#EXTINF:-1 group-title="Documenteries" logo="/img/icon.png",: Animal Planet   (s-6)
http://*********.m3u8
in channel2.m3u

Code: [Select]#EXTINF:-1 group-title="Misc" logo="/img/icon.gif", PAC-12 Net. (Bay Area) 1080P   (s-8)
    http://*********.m3u8
Here is the batch FILE I have so far

Code: [Select]echo off
cd Renamed_Files
for /f "delims=" %%i in ('dir /a-d/b *.m3u') do (
   set "NNAME="
   set "fname=%%~i"
   for /f "tokens=* delims=,(" %%f in ("%%~i") do if not defined nname set "nname=%%f"
   setlocal enabledelayedexpansion

   echo rename "!fname!" "!nname!.m3u"
   endlocal
)
pause
This gives me everything before the comma. If I change delims=,( to delims=( it gives me everything up to the Bracket, so I get the text I'm after, but I get all the text before it as WELL. The characters before the text I want are always ", and the characters after are always (s- if that helps.

This could be either a batch file or vbscript. Any help would be greatly appreciated.

1169.

Solve : rename xml using specific node variable position.?

Answer» HELLO friends I am trying to rename a group of xml files based on a specific node, which always changes position.
So far I have the following CODE that always works and cueando the position is fixed but as I say the position I need is variable.


The node that I need is the ONE that I set in image noIdentificacion =

this work with same position
echo off
for /f "delims=" %%Z in ('dir /b *.xml') do (
   for /f "tokens=12 delims== " %%A in (
     'find /i "noIdentificacion=" ^< "%%Z"'
       ) do REN "%%Z" "%%A.xml"
)



I hope and they can support me. Thank you.



[attachment deleted by admin to CONSERVE space]
1170.

Solve : How to insert the '&' Symbol in variables?

Answer»

I wanted to MAKE something like this,
set ab=&hello
But it will say Hello is not a command. ANYONE have an idea? Code: [Select]C:\>set ab=^^^&hello

C:\>echo %ab%
&hello Code: [Select]C:\>set "ab=^&hello"

C:\>echo %ab%
&hello

C:\>set "ab=&hello"

C:\>set /p ".=%ab%"<NUL
&hello

1171.

Solve : Merging External Hard Drives together batch question?

Answer»

Big Mess...

So I got a 4TB external drive and I was going to just create folders such as 80GB, 160GB, 500GB, 1TB, 1.5TB and xcopy the contents from these 5 external hard drives over to this 4TB drive, but then I got thinking that on many of these drives I have lots of redundant data that is going to waste space on the 4TB, and these drives will consume up to 3.240 TB. Maybe there is a way to merge the data all in one place and have only 1 copy of each file under same file name that is the same date/time stamp, but also have those files of older dates also copied over to the 4TB.

Windows is good when copying at detecting duplicates and prompting when they are detected asking what you want to do such as replace one date/time file with another or keep both copies. BUT the bigger mess is that I have the same files scattered among various paths and only really need 1 copy of each same file name at each date/time stamp, and paths aren't important.

Looking online I found that CCleaner has a duplicate feature which I never knew about. But it requires a very manual approach to what to do to each and every duplicate found with that date/time stamp. Looking for an automatic method.

Checking here to see if there is a nifty batch or other script method that someone can point me to that will copy only 1 copy of each filename of each date/time stamp to a destination drive so that if say I have 12 files all NAMED the same file name and of which there are 3 different date/time stamps, it will only copy the 3 different date/time stamped files of the 12 to the destination drive no matter of the pathing.

 To me if it was to be done in batch maybe it would involved a dynamic exclusion list file that has rules some how to know that a file of that name and date/time stamp has already been copied and to ignore xcopying another copy of it to the destination from from the source drive, but not sure how to build this exclusion list that would control how xcopy only copies a single instance of files which can be same file name with many date/time stamps and of non specific ( wild card ) pathing. The destination path doesnt need to be kept for duplicates so its ok if branches of the tree arent replicated from the source drives to the destination drive.

Two of my external source drives I know have heavy redundancy as for I wrote a program in a mixture of C and System Calls to Command Shell that I used to take CD-R and DVD-R data disc's and hit a key and it would create a folder named 1, 2, 3, 4 and xcopy the entire contents of the disc to the external drive at the folder iteration that it was currently at. Many backups were copied to the external drives and so there are some projects that have many same filename files and various date/time stamps. Whereas many people would be happy with the latest version of whatever file it is, I like having all files of same name of all date/time stamps so that if say I have a PROJECT that I decide I want to pick up with the source code from an earlier version of the code and code it differently, I can use that version as the base to build on from vs the newest version which may be completely reworked code which doesnt apply well to the original source type because lots would need to be chopped out and declarations removed etc to baseline it to build a different branch of code from earlier code as the best explanation of why I want all different date/time stamps of same file names.

The original source drives I am going to put into STORAGE as archives for read-only future use and the 4TB will be a singe drive that is used as a one place to find all my data dating back to the late 1980s early 1990s with even data from 5.25" disks in there in some places from years ago when I threw away trash bags full of floppies and burned it all to a 650MB CD-R in the late 1990s to save space as well as CD-R discs hold up better to age vs magnetic tape storage methods. But not all forms of media are age proof from dying and so I have constantly backed up all my data rolling forward onto newer means of data storage as well as multiple places with the data stored so that if say that 80GB external died tomorrow, the data is likely also on the 160GB that replaced it as the main drive years ago when 160GB use to be a lot of space 

Currently I am better at naming convention for my folders and projects to try to avoid like file names and add numeric version indications to projects such as file001 file002 or file09152017 to have a means of avoiding like file names as well as when wanting to find a specific file of a certain version its way easier. So my sloppiness of the past with my data I have improved upon but right now I just have a pile of data in various paths with lots of unneeded redundancy and figured I'd check here to see if anyone has a good script or ideas on how to achieve what I am trying to do.

Feeling kind of like there might be an easier method then current idea of that it would require exporting a DIR dump and have a script that then copies 1 line for each file name of each unique date/time stamp no matter of path, and then an XCOPY that runs down through that list with each line on it executed with an individual file copy to destination for only one instance if like file names of like date/time stamps, but all date/time stamps that are different copied to destination.

Or maybe even there is a tool out there other than batch and other than xcopy that can do this that I am unaware of. I am thinking there must be others out there who also have a mess of data all thrown into one place or multiple places with redundancy that is unnecessary to have say 12 files on the same drive of the same date/time stamp and only 1 needed etc. 

Even if it was me copying via xcopy all data to the 4TB drive and running a batch or script that kills off duplicates of same filenames of same date/time stamp that would work too as a more simplistic approach than detecting duplicates during the copy process. So after the copying is done its basically just a redundancy garbage cleanup but all date/time stamp versions of same file name there being one of each unique time stamp of that same file name, but if the file is located in multiple paths only the first instance of that file with that date/time stamp is protected and all others of same name and date/time stamp deleted or tossed into a folder named duplicates which i can look through quickly and then delete on my own etc.

I'm sure it's possible in batch- which I have to say because no matter how impossible I think something is somebody like Salmon Trout shows up with a batch file - but I think that the files being in different paths might complicate things a bit.

Presuming I had a similar task (I don't, but it's fun to pretend) I would probably have written a program to do it.

The program would effectively be given a Source Directory, a Target directory, and a list of other directories. I'm thinking of the psuedocode as such:

if there are other directories specified
    for each file in all of those other directories
        calculate a unique hash for this file. (in your case, this would be the filename and the last modified date, but it could of course also be based on content of the file too)
        store that unique value in a HashSet. If it already exists, then don't try to add it (If there is already an entry then that's a collision, which would mean that the file is duplicated within the specified "other" folders)
        (It would also be possible to index additional information- storing the path of that file for example, via a HashMap rather than a HashSet)
   Now, process all the files in the specified drive.
        With every file calculate a hash in the same way as above.
        If that hash already exists in the Map/Set
            then we know that this file is already in one of those other folders and we skip it.
            otherwise, copy the file to the target directory, preserving the path (eg E:\some\folder\place\foundfile.txt get's copied to T:\500GB as T:\500GB\some\folder\place\foundfile.txt



In your case then it would mean using Xcopy to copy the first drive, then using this imagined program for each subsequent copy, including the "other" folders as the folders copied too so far. Each new copy would basically ignore files that were already present in those other directories.

It would also be possible to do something fancy, like instead of doing nothing, it creates a hard link to the file that was found in the other folders. This would result in the directories all preserving exactly what they looked like on the drive, but all duplicated files (based on the hash) would share the same data. and not take up any additional space. Or it could write up a "report" for each target listing the file paths that weren't copied and where they already existed.


       
    Thanks BC for your insight on this. Also I like your multiple directions that are different than my hypothetical but possible ones. The hard link was an interesting one. One file and links at the multiple paths that point to 1 file of the same name and date/time stamp.

But it got me thinking.... aren't hard and soft links something that is mapped on a single system that by which they were created from, where external drive used by a different computer it wouldnt work out the same when accessing data at the external directly via USB connection? Also if other computers treat the 4TB drive as different drive letters not sure if the links would break or if they have wildcard to device root of external drive no matter of assigned drive letter if they travel with the drive to work on any modern Windows based computer. 

Quote

It would also be possible to do something fancy, like instead of doing nothing, it creates a hard link to the file that was found in the other folders. This would result in the directories all preserving exactly what they looked like on the drive, but all duplicated files (based on the hash) would share the same data. and not take up any additional space. Or it could write up a "report" for each target listing the file paths that weren't copied and where they already existed.
Hard links work via NTFS. Basically, NTFS file structures basically have a MFT entry that SAYS what the file is named and points at where the data for the file is. Hard Links are when more than one MFT Entry points at the same data. Of course there are caveats- changing one changes all other "files" pointing at that data for obvious reasons- though those might be desirable side effects anyway.

Thanks for your clarification on how hard links work BC. I always thought that the links were system bound and not part of the master file table. While the MFT has an index of all data I always thought the system that the drive connects to keeps track of hard and soft links.

I think I am going to just manually go through and target the larger redundant files and work my way down from there using CCleaner's duplicate finder feature. CCleaner has ability to select search for duplicates of greater than a specific size that I can specify. I set it to greater than 100MB and then found duplicates of Linux ISO's and stuff that I dont need to have 6 copies of Linux Mint 9 LTS.

I was messing around with some ideas and then put a stop to them when I realized that for each duplicate my routine was going to have to search through the entire drive with every pass and its slow and very inefficient. CCleaner has a export to text file for duplicates and I was going to use this as a cheat sheet for my program to know what and where to target duplicates but realized that I probably should just manually pick away at this, as well as there is some data I am finding that I really dont need to keep around anymore so I am trashing some stuff ENTIRELY that I dont have a purpose for such as Open Office installer Version 3.2.1 so I guess I will pick away at it.
1172.

Solve : Send commands to open application from command prompt?

Answer»
I was hoping someone might be able to help me with sending commands to the applications I just opened.
I know each application is different perhaps you could teach me how to find these commands?

I want to EVENTUALLY be able to call a single batch file and launch a game or application (let's use STARCRAFT for an example) then log in, and start a game and run commands to play the game.

I am under the understanding this is POSSIBLE with MS-DOS.
However, in the meantime perhaps we should just start with this example.

I would like to launch VS2015 Command Prompt and MAKE a call to unlock a file. I cannot seem to figure out how to make a call to the VS Developer Command Prompt after it is opened. Can you please help me with this please



echo off
set "pathA=C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\"
set path=%path%;%pathA%
start /max  "Developer Command Prompt for VS2015".lnk  cd "C:\Program Files (x86)\Microsoft Visual Studio 14.0\"
echo. "C:\temp\Test.txt"


Quote from: Skylark on September 14, 2017, 06:24:36 PM
I am under the understanding this is possible with MS-DOS.
No and very doubtful you are using MS-DOS.  A batch file cannot INTERACT with Graphical User Interfaces.  If you need to do that try using Vbscript with Sendkeys method or use a program like AutoIt or AutoHotkey.Thank you for saving me a boatload of time. 
I appreciate your help, I will start learning vb now.
1173.

Solve : Batch for closing 2 instances of software?

Answer»

Is it possible to close two instances of the same programs if found running in process, like two myprogram.exe.
If there is only one than leave it but if find two it will close both.
Is tha possible with batch?You can use tasklist to count how many instances of a program are running. if that number is greater than 1 kill them all.

set nr=0
for /f "delims=" %%A in ('tasklist ^| find "notepad.exe"') do set /a nr+=1
if %nr% gtr 1 taskkill /F /im "notepad.exe"
Thank you, exactly what I need.This kills all my instances of notepad it doesn't leave any up.
  Quote from: Skylark on September 15, 2017, 10:26:56 AM

This kills all my instances of notepad it doesn't leave any up.

That's what you asked for.

Quote from: Skylark
Thank you, exactly what I need.


Apparently a different user who didn't read the OP original requirements. Quote from: BC_Programmer on September 15, 2017, 12:26:58 PM
Apparently a different user who didn't read the OP original requirements.
This statement is pretty cut and dry in English English or American English.   
Quote from: Salmon Trout on June 28, 2017, 01:27:23 PM
if that number is greater than 1 kill them all.
Quote from: BC_Programmer on September 15, 2017, 12:26:58 PM
Apparently a different user who didn't read the OP original requirements.
I didn't notice it was a different user. I did think that 2 and a half months was a bit long to decide it didn't do what they wanted.
Currently have a similar ISSUE with a product called FIRESTORM Viewer and I have been just manually going in to task manager and killing the extra instances of a executable that stays active when the viewer exits. I didnt catch this issue until opening and closing Firestorm Viewer about 5 times and then noticed some unexpected lag where the cores get weighed down with extra instances running but no window active for them etc. It seems as though this Viewer has a bug where it doesnt kill all threads on exit and starts to stack multiples. The biggest issue when killing the other instances is that if you select the WRONG one you kill the currently active session vs the orphan remaining exe's that you want gone. So I just kill all of them now, and start fresh.

Killing all instances of the exe that acts up and then relaunching is the best method I found.  If you used tasklist in a batch with the /v (verbose) and /fo:csv switches you could catch the window title in full

This is the header:

"Image Name","PID","Session Name","Session#","Mem Usage","Status","User Name","CPU Time","Window Title"

For example, this session of Firefox right now shows up:

"firefox.exe","3292","Console","1","711,312 K","Running","MIKEANDBARBIE2\Mike","0:08:51","Preview - Re: Batch for closing 2 instances of software - Mozilla Firefox"

You can use for /f with comma delim and catch the various tokens, e.g.
Code: [Select]for /f "tokens=1-10 delims=," %%a in ('tasklist /v /FO:CSV ^| find /i "firefox"') do echo PID %%b WIN title %%j Code: [Select]PID "3292" Win title "Preview - Re: Batch for closing 2 instances of software - Mozilla Firefox"
You could present the PID (token 2) and window title (token 10) of each one to the user in a list and then invite them to type a PID to kill using taskkill
if each instance of Firestorm Viewer has a different window title that WOULD work but if the orphaned threads have not got active windows I guess you'd need some other way to ID the ones you want to kill. I think the window title would show up as "N/A". However if the image name contained "Firestorm" maybe you could just nuke that PID.

This here is the bug...

https://jira.phoenixviewer.com/browse/FIRE-17876

llceflib_host is the executable that starts to stack multiple instances. I have been just closing out the active window and going into task manager and sort alphabetical and kill all llceflib_host processes. Then relaunch firestorm viewer and its ok again. It only seems to happen when the viewer is exited and relaunched again as if there is a issue with garbage clean up at shutdown of services. No windows open with these services. I looked to see if there was a way to associate which one goes with the active window and which ones are orphan but its just pretty simple to close out the viewer and go to task manager sort alphabetical and kill all of the llceflib_host processes, then launch a fresh launch of firestorm. 

1174.

Solve : How can you tell an old program to use shrt names??

Answer»

Yes, I am talking about very old programs. Some will choke on a long file name or a file name with some odd chars in it.
Was there not some way lyou can make the old program use the short  name? And when it writes the short name file back out to the system, it inherits the long file name automatically. Is that right?

So I want to make a batch file that does this.
 find the short name of a file that has a long name.
 call the old program  using short name
 let the old program write the short name file back to the system
 report if an error was made

Is that possible?  Just asking.
If you ignore  this, I will assume it is a BAD idea.  I'm sure salmon Trout or one of the other more experienced batch folks can give a better solution than I.

The first issue is that no- when a program that doesn't support long file names (MS-DOS or 16-bit windows programs) writes back to the file, the long file name is not really preserved. There might be some very specific cases where it is- in particular, it depends if the program is writing to that file specifically, or deleting the existing file and recreating it. That was a common approach to saving files so it is much more common to find that the long name is basically removed altogether.

However, you can pretty easily workaround this with the batch. You can get the short name, run the program, wait for it to exit, and then afterwards you rename (move) the short named file to the original long name.

This has two batch files. One which is used to get the short file name, which I called getshort.bat:

Code: [Select]ECHO OFF
echo %~s1

and another to make use of it and run the program, which I've called runshort.bat:

Code: [Select]echo off
echo running program "%1" with shortened filename of "%2"
set fullname=%2
for /f %%p in ('getshort %2') do set shortfile=%%p
echo shortfilename is %shortfile%
start /wait %1 %shortfile%
move %shortfile% %fullname%

which is executed as runshort "C:\Program files (x86)\oldsoft\oldprogram.exe" "C:\Users\My User Account\Documents\Some WEIRD Folder\Unusually titled files\a study on the various kinds of birds which have nested within my beard.opd"

which will run the program with the short file name, and then afterwards rename that short name to the long name; if the program did nothing or rewrote the file properly, it will fail and do nothing, but if the program rewrote the file and the long name was lost, renaming the short name to the long name will effectively restore it.

The only caveat is that it might not have the same short file name afterwards, so MRUs within the old program might not function correctly.

Since I'm on 64-bit windows, there are short names, but I don't have any way to directly run older applications, so I can't directly test it with such a program.

Thanks BC,
The program I have is not a 16 bit program. I think I will that on my 64 bit machine and see. As it is now, if a file goes beyund the 8.3 spec, I get a bad file mode.
I  wrote  it so that it writes to a TEMPORARY file and then at the end it copies the temp to the original name.

So for the present, I have to rename t he files my hand. I still have a lot of flies to process, so I was hoping for a solution that  would let me automate the job.

Well,  it is one of my own programs so I should re-write it in a NEWER compiler. But it was easier for me to just ask for a quick workaround.
Thanks again.

(Now I expect  Salmon trout will come along and do it in lone line.) 
16bit programs cannot run on 64bit OS last time I checked.

But the provided solution should work if you pass it the short file name.  It should also be able to write to the short file name.

Easy enough to test that theory from the cmd prompt.
Code: [Select]H:\>type nul>"really long file name 123456789.txt"

H:\>dir /X really*
 Volume in drive H is DATA
 Volume Serial Number is D2F3-49FA

 Directory of H:\

09/06/2017  09:42 AM                 0 REALLY~1.TXT really long file name 123456789.txt
               1 File(s)              0 bytes
               0 Dir(s)  168,122,675,200 bytes free

H:\>echo blah>really~1.txt

H:\>type really~1.txt
blah

H:\>notepad really~1.txt

H:\>type really~1.txt
blah
notepad edit

1175.

Solve : how to avoid pop up box for password in windows batch script?

Answer»

I am trying to encrypt and decrypt a file using a GPG software using BATCH SCRIPT. Every thing goes FINE for encryption but when i try to decrypt it prompts for password which comes as a message box but i want to avoid this because this script has to be called in some other application and we cannot automate this unless we provide the password in actual script itself. Can some one help me in this regards.GPG has a passphrase option.
This is how I decrypt using gpg
Code: [SELECT]gpg.exe --batch --passphrase Password -o  "Outputfile.txt" --decrypt "Input.gpg"Thanks a lot Squashman, this worked for me.

1176.

Solve : A Path with date variables?

Answer» HELLO everyone.

I would like to OPEN a folder with DATE variables inside.

How can I do that ?

Example I am trying

Y:\Folder\%yyyy%\%mm%.%yyyy%\

where yyyy is the year of the system (windows 8.1) and mm is the month

Y:\Folder\2017\08.2017

Best Regards
Here we go :
Code: [Select]echo off
Title GET DateTime with Wmic
for /f "tokens=2 DELIMS==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YYYY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%"
set "Min=%dt:~10,2%"
set "Sec=%dt:~12,2%"
Set "DateTimeVar=%YYYY%%MM%%DD%%HH%%Min%%Sec%"
echo YYYYMMDDHHMinSec = %DateTimeVar%
echo Y:\Folder\%yyyy%\%mm%.%yyyy%\
pauseThanks a lot Hackoo

Best Regards
1177.

Solve : script file to add date to file name?

Answer»

Hello Folks,

Have a small problem that I'm hoping I COULD get some assistance with.  I currently have a batch file which that that ftp's a .txt to a desired location. I want to rename this text file with current month in abbreviation and year  to the filename my filename is MISFTP.txt it should be rename to be something like 102.txt  i.e 102oct'17


USER user   
PASS password
CONNECT "gggggg"
ONERROR GOTO DISCONNECT
cd MISFTP
MPUT MISFTP.txt
RNFR /home/ssattu/MISFTP/MISFTP.txt
RNTO /home/ssattu/MISFTP/102.txt
LABEL DISCONNECT
CLOSE
You don't need to use the rename command.  You can name it when you use the put the command.
Code: [Select]PUT MISFTP.txt 102oct17.txtIf you are LOOKING for a way to get the month name and century into variables to use to build your FTP script, this should help you with that.
Code: [Select]echo off
setlocal EnableDelayedExpansion
set m=100
for %%m in (January February March April May JUNE JULY August September October November  December) do (
   set /A m+=1
   set month[!m:~-2!]=%%m
)
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /VALUE') do set "dt=%%a"
set cc=%dt:~2,2%
set mm=%dt:~4,2%
set monthName=!month[%mm%]!
echo Month Name: %monthName%
echo    Century: %cc%
pause

1178.

Solve : Getting "!" and other difficult characters to encrypt.?

Answer»

I've managed to get most the special characters but
Characters like "!" And "*" are giving me problems.
Possible work arounds?

I can elaborate if it's not clear to understand.

Code: [Select]title Encrypt Batch File
color 0a
echo off
MODE con:cols=50 lines=2
echo Encrypt text files.
pause
cls
mode con:cols=100 lines=2
 
set CaseType=97
> Randalphabet.vbs echo randomize timer
>> Randalphabet.vbs echo RandAlphabet=""
>> Randalphabet.vbs echo Do
>> Randalphabet.vbs echo randchar = Chr(Int(26*Rnd+%CaseType%))
>> Randalphabet.vbs echo If Instr(RandAlphabet, randchar) = 0 Then RandAlphabet = RandAlphabet ^& randchar
>> Randalphabet.vbs echo if len(RandAlphabet) = 26 Then exit Do
>> Randalphabet.vbs echo Loop
>> Randalphabet.vbs echo wscript.echo RandAlphabet
for /f "delims=" %%A in ('cscript //nologo Randalphabet.vbs') do set Randalphabet=%%A
del Randalphabet.vbs
 
set /a key1=%random% %% 3%random:~-1%%random:~-1% + 1
set /a key2=%random% %% 3%random:~-1%%random:~-1% + 1
set /a key3=%random% %% 3%random:~-1%%random:~-1% + 1
set /a key4=%random% %% 3%random:~-1%%random:~-1% + 1
set /a key5=%random% %% 3%random:~-1%%random:~-1% + 1
 
set /a count1=%random% %% 2
if "%count1%"=="0" set "math1=+" & set "math2=-"
if "%count1%"=="1" set "math1=-" & set "math2=+"
if "%math2%"=="+" set "math3=-" & set "math4=+"
if "%math2%"=="-" set "math3=+" & set "math4=-"
 
set /a count2=%random% %% 27
if %count2%==1 set separator=È
if %count2%==2 set separator=»
if %count2%==3 set separator=¼
if %count2%==4 set separator=º
if %count2%==5 set separator=Í
if %count2%==6 set separator=¿
if %count2%==7 set separator=¹
if %count2%==8 set separator=µ
if %count2%==9 set separator=Ø
if %count2%==10 set separator=¸
if %count2%==11 set separator=Ð
if %count2%==12 set separator=×
if %count2%==13 set separator=Ù
if %count2%==14 set separator=Ï
if %count2%==15 set separator=Ô
if %count2%==16 set separator=´
if %count2%==17 set separator=Ñ
if %count2%==18 set separator=½
if %count2%==19 set separator=³
if %count2%==20 set separator=Ò
if %count2%==21 set separator=¾
if %count2%==22 set separator=Å
if %count2%==23 set separator=Ä
if %count2%==24 set separator=¶
if %count2%==25 set separator=Ç
if %count2%==26 set separator=Ë
if %count2%==27 set separator=·
 
:options
set /p "FILEA= Enter the name of the text file that you wish to encrypt (Example; "Somefiletxt") : "
cls
if not exist %FILEA% echo The file "%FILEA%" does not exist. & pause & cls & goto options
set /p "FILEB= Enter the name of the decrypter that will be generated (Example; "Decrypter.bat") : "
cls
set /p "FILEC= Would you like to separate the encrypted text from the decrypter? (Y/N) : "
cls
 
Setlocal EnableDelayedExpansion
echo > "%FILEB%" echo off
echo >> "%FILEB%" mode 200
Setlocal EnableExtensions
for /f "delims=" %%A in (%FILEA%) do (
Set /a C+=1
Set X[!C!]=%%A
set code=%%A
set chars=0123456789%Randalphabet%^|^^%%^&^<^>^{^}^[^]^(^)
for /l %%C in (10 1 48) do (
for /f %%D in ("!chars:~%%C,1!") do (
set /a math=%%C*%key1%*%key1%-%key1%/%key1%%math1%%key2%*%key2%-%key2%/%key2%%math2%%key3%*%key3%-%key3%/%key3%%math1%%key4%*%key4%-%key4%/%key4%%math4%%key5%*%key5%-%key5%/%key5%+5
for /f %%E in ("!math!") do (
set "code=!code:%%D=%separator%%%E!"
)
)
)
if /i "%FILEC%"=="N" echo >> "%FILEB%" echo ^>^> lmotqocflhoi.txt !code!
if /i "%FILEC%"=="Y" echo >> "lmotqocflhoi.txt" !code!
)
 
echo >> "%FILEB%" Setlocal EnableExtensions EnableDelayedExpansion
echo >> "%FILEB%" for /f "delims=" %%%%A in (lmotqocflhoi.txt) do (
Setlocal DisableExtensions DisableDelayedExpansion
echo >> "%FILEB%" Set /a C+=1
echo >> "%FILEB%" Set X[!C!]=%%%%A
echo >> "%FILEB%" set gcfnipvbergt=%%%%A
echo >> "%FILEB%" set pspfckinvcrn=0123456789%Randalphabet%^^^|^^^^%%%%^^^&^^^<^^^>^^^{^^^}^^^[^^^]^^^(^^^)
echo >> "%FILEB%" for /l %%%%C in (10 1 48) do (
echo >> "%FILEB%" for /f %%%%D in ("!pspfckinvcrn:~%%%%C,1!") do (
echo >> "%FILEB%" set /a qmgsmphoomrhmu=%%%%C*%key1%*%key1%-%key1%/%key1%%math1%%key2%*%key2%-%key2%/%key2%%math2%%key3%*%key3%-%key3%/%key3%%math1%%key4%*%key4%-%key4%/%key4%%math4%%key5%*%key5%-%key5%/%key5%+5
echo >> "%FILEB%" for /f %%%%E in ("!qmgsmphoomrhmu!") do (
echo >> "%FILEB%" set "gcfnipvbergt=!gcfnipvbergt:%%%%E=%%%%D!"
echo >> "%FILEB%" )
echo >> "%FILEB%" )
echo >> "%FILEB%" )
echo >> "%FILEB%" for /f %%%%F in ("!gcfnipvbergt!") do (
echo >> "%FILEB%" set "gcfnipvbergt=!gcfnipvbergt:%separator%=!"
Setlocal EnableExtensions EnableDelayedExpansion
echo >> "%FILEB%" echo ^^!gcfnipvbergt^^!
echo >> "%FILEB%" )
echo >> "%FILEB%" )
if /i "%FILEC%"=="N" echo >> "%FILEB%" del lmotqocflhoi.txt
echo >> "%FILEB%" echo.
echo >> "%FILEB%" pause
 
echo > "poly.vbs" randomize
echo >> "poly.vbs" set daeh=createobject("scripting.filesystemobject")
echo >> "poly.vbs" set iftkmc=daeh.opentextfile(%0,1)
echo >> "poly.vbs" lrur=iftkmc.readall
echo >> "poly.vbs" gsvlabhrht="gcfnipvbergt pspfckinvcrn qmgsmphoomrhmu lmotqocflhoi":hheaqqhtloeset=split(gsvlabhrht," ")
echo >> "poly.vbs" for each kbjalobheu in hheaqqhtloeset
echo >> "poly.vbs" for cunuvblq=1 to int(rnd*6)+2
echo >> "poly.vbs" tjai=tjai+chr((int(rnd*22)+97))+chr(int(rnd*22)+97)
echo >> "poly.vbs" next
echo >> "poly.vbs" lrur=replace(lrur,kbjalobheu,tjai):tjai=""
echo >> "poly.vbs" next
echo >> "poly.vbs" set iftkmc=daeh.opentextfile(%0,2,1)
echo >> "poly.vbs" iftkmc.writeline lrur
echo >> "poly.vbs" Set fso = CreateObject("Scripting.FileSystemObject")
echo >> "poly.vbs" fso.DeleteFile WScript.ScriptFullName
echo >> "poly.vbs" iftkmc.close
start "" "poly.vbs
Is there some reference work that outlines the algorithm you use?

Normally, when ASCII text is to be encrypted, all control chars must be escaped to something else. The should not be a need to makes exceptions for the other chars. Which means that using only DOS commands is not really good idea. MANY chars have special meaning in DOS and it is hard to come up with an escape method for them.
I found something, Google this

"viewtopic.php?t=1485 dos tips" without quotes
Click the first link that appears.

It's related to the situation but it's to difficult for me to understand how to implement.The algorithm is borrowed from technology crazys YouTube channel's tutorial on batch ENCRYPTION. I basically made his script more advanced but I'll add notes to my script too in due time. Will take a lot of explanation. Quote

Possible work arounds?
Actually learn what you are doing instead of copy-pasting from incompetent youtubers?Code is very much changed from original source and this was for personal use, also I asked him if it was ok.  I know what everything in the source does line for line so what do you mean actually learn what your doing?The source is clearly not just copied and paste, it clearly has been greatly modified for more useful purposes, the algorithm isn't even entirely the sameYou don't have to criticize I have zero intention of stealing credit from other youtubers. Like it seriously offends me how you make such a claim. I've been breaking this script down and modifying it and you just act like all I did is copy, paste, added some REM statements and happy faces and boom a brand new script. Like you could at least have looked at the differences in the scripts. I'll go somewhere else for help jesh.I get your like an expert and all but I have been trying to learn, and your completlying dising on me and I've done nothing wrong. There is a difference from borrowing a script, modifying it, etc, from just taking the script and copy and pasting, I even told you who the original algorithm came from so like Im not plagiarizing or anything. All I did is paraphrased his source and made it much more advanced than the original.If the source is nearly 70% changed then I have been learning from what i code.if you knew what you were doing you would not be having issues determining why certain characters were causing problems .

I wasn't even intending to accuse you of stealing. They provide it for free, after all. Regardless of how much it may have been altered though, it started with a rotten base- The 'incompetent youtuber" part is probably the major takeaway there. I doubt they even wrote the batch file to start with anyway. There are innumerable youtube channels started by upstart teenagers who's parents and family have told them all their life  they will be the next "Bill Gates" because they can log in to face book or use the Command Prompt. Some of them take it to heart and start pretty much writing their memoirs before they are out of high school, like that guy. I mean, at least I had the good sense to wait until I was 21 to be a smartass know-it-all.

In any case * and ! are not inherently different than any other character when it comes to these kind of transformation algorithms, so I'd guess that it is related to ! and * having special meaning within the Command Prompt itself, possibly caused entirely by the many layers of unnecessary indirection that are present here, where it constructs accessory batch files and scripts via echo commands. You might start by changing it to not delete these accessory files and examining the batch and VBScript files it creates as they may be where the issue lies, likely in the form of unescaped characters.

I wasn't saying you was accusing me of stealing I was just pointing out that I wasn't.

I understand but what you mean, with the whole youtube and where it came from, I do agree, but i have no where to learn from. I do understand what this script does, i learned it line for line. what I don't understand is the whole trying to escape "!" I have tried adding "^^!", I know how to escape it, just not in this situation. I only have general knowledge of the language, And I know like a fair amount of cmd now, but don't understand everything in entirety, i can read some code and understand it well and other scripts I just can't figure out what I'm looking at. Like honestly I put a decient amount of work in the above script, almost more than the original script even had. But I don't know everything, I'm not a mastermind coder. I only applied what I knew I could do to the script, that's why I was asking questions here. Because  I'm trying to learn and it's difficult when there is so little information anywhere on the Internet about command line, YouTube is filled with horrible noob tutorials, every website that helps individuals require at least that person to create his source before they can actually help that person. It's not necessary a big issue, but when i first started out trying to learn, it made it almost impossible to learn anything because I wasnt allowed to learn from others code or have had the knowledge to create my own. Im a person who learns from books, and there is very few books on commamd line that I've found.

You say I should learn but I really have been teaching myself a lot more than my old lazy bad habit days, I've been on dos tips breaking down scripts trying to understand them and such. I just do this because I'm really interested in it, but even with all the tutorials, breaking down code, and etc, I'm still not learning how to stretch it into something that I can create by scratch.And I'm not even trying to be a smartass, I'm just trying to learn, honestly, and I was only going to use the script personally. I don't think for a split second that I'm possibly even as remotely close to being as good as you guys or even the guys at dos tips. But where do I go when there isn't anything good anywhere, all tutorials just show the basics and never get into deep details. Again, you were not the smartass to which I referred, but rather the youtuber. They are unreliable as a resource, as they barely understand the material themselves. This tends to be the case for the majority of youtube channels who create tutorials like this, unfortunately.

As I mentioned, The script creates additional scripts as part of it's operation. I would suspect the issue lies there, If you REMOVE the segments of code responsible for deleting those helper files, and then you can examine the contents of the files generated and make sure there are no characters that aren't escaped when they should be, or otherwise test/validate those segments of the entire operation.
1179.

Solve : Usinf CMD line for advanced search.?

Answer»

The standard search in Windows, apparently, has few options of AND with NOT.
Correct me if I am wrong.
Problem: I think I have TXT files somewhere with old e-mails ADDRESS. But I am not sure. If I had a perfect memory, I would not need a computer.
Le's same my name is Gordan, it is not, and and my e-mail might have been  ymail.com
I know I have files with [email protected], but I want to see if there were any other user names I had used on ymail in the past year..
So, I want to find all text files that have:

Code: [Select]ymail.com AND NOT [email protected]
How can I do that from the command line?

Either in Windows XP or Windows 7.

Thank you all. 
I have just used notepad to open file and then use the FIND function in text files to find content. If the file is too big for notepad I have opened it using Word and then use FIND in which for an e-mail I would think all you would need to search for is as for it probably has no other purpose in WHATEVER files you have. If you have multiple files and not which which ones have in them then you would likely want to use a search for the symbol in files and then flag which files have a in them. Then use notepad or word with those files that were positive detections for sign in them. And use the FIND function to show all matches to symbol in the file in which if there are e-mail addresses then it should show all of them.

One thing you could do is get all of your text files piled into a known location such as connect a thumb drive if the thumb drive is at E: run xcopy c:\*.txt e:\TextFiles\*.* /s/h/y and then you will have all known text file locations copied to TextFiles folder you then can navigate through and figure out which files are just readme or log files from files you created that might contain e-mail addresses and search those for Agent Ransack has Boolean search. It's very useful, fast and free, (and it's British!) and works on Vista and later. Click the image to make it bigger.

https://www.mythicsoft.com/agentransack/download




Thanks, That is want I need. 
BTW: For Windows XP you need to find the older version of 2014.
Old Version Agent Ransack

The current version is for Vista and up. 
It can add itself to the right-click context menu in Windows Explorer, and you can also run it from the command line.
Hi 
I just modified my old script to search only on text files ( The Original script can be found here https://pastebin.com/raw/ADdjPEfH )
So, just give a try and tell how it works on your side 
Code: [Select]ECHO OFF
REM The Original script can be found here https://pastebin.com/raw/ADdjPEfH
Rem This is a modified version to search only on text files
Title Scan a folder and Search a string in multi-files by (c) Hackoo 2017
mode 78,2
Call :init
Call :inputbox "PLEASE enter something to search :" "Search a string in multi-files by (c) Hackoo 2017"
If  "%input%" == ""  Color 0C & (
echo(
echo           You must enter a string to continue with this program
pause>nul & exit
) else (
Call :BrowseForFolder "Please Choose source folder to scan for %input%" SourceFolder
    Setlocal EnableDelayedExpansion
    If defined SourceFolder (
        echo(
        echo             You chose "!SourceFolder!" as source folder & pause
    ) else (
        echo(
        Color 0C & echo                    The source folder is not defined ... Exiting ......
        Timeout /T 2 /nobreak>nul & exit
    )
)
::******************************************************************************************
Set "ROOT=%SourceFolder%"
::Does string have a trailing back slash ? if yes, so, we remove it !
IF %ROOT:~-1%==\ SET ROOT=%ROOT:~0,-1%
Rem you can add also those extensions txt vbs js json hta php htm html xml csv rtf
SET "EXT=txt"
SET "Count=0"
set "Word2Search=%input%"
Set "NewFolder2Copy=%userprofile%\Desktop\CopyFiles_%Word2Search%"
Set "LogFile=%~dp0%~n0_%Word2Search%.txt"
SETLOCAL enabledelayedexpansion
REM Iterates throw the files on this current folder and its subfolders.
REM And Populate the array with existent files in this folder and its subfolders
For %%a in (%EXT%) Do (
Call :Scanning "%Word2Search%" "*.%%a"
Call :PS_Sub 'information' 10 '"Scanning now for """%Word2Search%""" on """*.%%a""" . . . "' "'Please wait. . . Scan is in progress on all """*.%%a""" . . .'" 'info' 5
FOR /f "delims=" %%f IN ('dir /b /s "%ROOT%\*.%%a"') DO (
( find /I "%Word2Search%" "%%f" >nul 2>&1 ) && (
SET /a "Count+=1"
set "list[!Count!]=%%~nxf"
set "listpath[!Count!]=%%~dpFf"
)
) || (
( Call :Scanning "%Word2Search%" "%%~nxf" )
)
)
::*******************************************************************
:Display_Results
cls & color 0B
echo wscript.echo Len("%ROOT%"^) + 20 >"%tmp%\length.vbs"
for /f %%a in ('Cscript /nologo "%tmp%\length.vbs"') do ( set "cols=%%a")
If %cols% LSS 50 set /a cols=%cols% + 28
rem If %cols% LSS 50 set /a cols=%cols% + 15
set /a lines=%Count% + 17
Mode con cols=%cols% lines=%lines%
echo(
Call :color 0A " ------------------------------------------------" 1
ECHO   Folder : "%ROOT%"
Call :color 0A " ------------------------------------------------" 1
rem If Exist "%LogFile%" Del "%LogFile%"
rem Display array elements
for /L %%i in (1,1,%Count%) do (
set "msg=[%%i] - !list[%%i]!"
echo !msg!
)
ECHO(
ECHO Total of [%EXT%] files(s) that contains
Echo the string "%Word2Search%" is : %Count% file(s)
echo.
Call :color 0D "Type the number of file that you want to explore" 1
echo(
Call :color 0C "To save results into a LogFile just type 'LOG'" 1
echo(
Call :color 0A "To copy all files found just type 'Copy'" 1
set /p "Input="
For /L %%i in (1,1,%Count%) Do (
    If "%INPUT%" EQU "%%i" (
        Call :Explorer "!listpath[%%i]!"
    )
IF /I "%INPUT%"=="Log" (
Call :Save_Results
)
IF /I "%INPUT%"=="Copy" (
Call :CopyFiles
)
)   
Goto:Display_Results
::****************************************************************************
:Save_Results
If Exist "%LogFile%" Del "%LogFile%"
rem Display array elements and save results into the LogFile
(
Echo   ------------------------------------------------
ECHO   Folder : "%ROOT%"
echo   ------------------------------------------------
)>"%LogFile%"

for /L %%i in (1,1,%Count%) do (
set "msg=[%%i] - !list[%%i]!"
echo !msg! -- "!listpath[%%i]!" >> "%LogFile%"
)

(
ECHO.
ECHO Total of [%EXT%] files(s^) : %Count% file(s^) that contains the string "%Word2Search%"
)>> "%LogFile%"
Start "" "%LogFile%"
Goto:Display_Results
::****************************************************************************
:Scanning <Word> <file>
mode 78,3
Cls & Color 0A
echo(
echo      Scanning for the string "%~1" on "%~2" ...
goto :eof
::****************************************************************************
:Explorer <file>
explorer.exe /e,/select,"%~1"
Goto :EOF
::****************************************************************************
:init
prompt $g
for /F "delims=." %%a in ('"prompt $H. & for %%b in (1) do rem"') do set "BS=%%a"
exit /b
::****************************************************************************
:color
set nL=%3
if not defined nL echo requires third argument & pause > nul & goto :eof
if %3 == 0 (
    <nul set /p ".=%bs%">%2 & findstr /v /a:%1 /r "^$" %2 nul & del %2 2>&1 & goto :eof
) else if %3 == 1 (
    echo %bs%>%2 & findstr /v /a:%1 /r "^$" %2 nul & del %2 2>&1 & goto :eof
)
exit /b
::***************************************************************************
:BrowseForFolder
set "psCommand="(new-object -COM 'Shell.Application')^
.BrowseForFolder(0,'%1',0,0).self.path""
for /f "usebackq delims=" %%I in (`powershell %psCommand%`) do set "%2=%%I"
exit /b
::***************************************************************************
:InputBox
set "input="
set "heading=%~2"
set "message=%~1"
echo wscript.echo inputbox(WScript.Arguments(0),WScript.Arguments(1)) >"%temp%\input.vbs"
for /f "tokens=* delims=" %%a in ('cscript //nologo "%temp%\input.vbs" "%message%" "%heading%"') do (
set "input=%%a"
)
exit /b
::***************************************************************************
:PS_Sub $notifyicon $time $title $text $icon $Timeout
PowerShell  ^
  [reflection.assembly]::loadwithpartialname('System.Windows.Forms') ^| Out-Null; ^
 [reflection.assembly]::loadwithpartialname('System.Drawing') ^| Out-Null; ^
 $notify = new-object system.windows.forms.notifyicon; ^
  $notify.icon = [System.Drawing.SystemIcons]::%1; ^
  $notify.visible = $true; ^
  $notify.showballoontip(%2,%3,%4,%5); ^
  Start-Sleep -s %6; ^
  $notify.Dispose()
%End PowerShell%
exit /B
::****************************************************************************
:MakeCopy <Source> <Target>
If Not Exist "%~2\" MD "%~2\"
Copy /Y "%~1" "%~2\"
goto :eof
::****************************************************************************
:CopyFiles
cls
mode con cols=80 lines=20
for /L %%i in (1,1,%Count%) do (
echo Copying "!list[%%i]!" "%NewFolder2Copy%\"
Call :MakeCopy "!listpath[%%i]!" "%NewFolder2Copy%">nul 2>&1
)
Call :Explorer "%NewFolder2Copy%\"
Goto:Display_Results
::*****************************************************************************
[attachment deleted by admin to conserve space]Thanks for sharing Hackoo ... gonna have to try out your batch tonight on my home pc. Looks interesting. Also Salmon shared the Agent Ransack method and I forgot that that has a search feature for ascii/string data. I use Agent Ransack because Windows 7 doesnt have a good built in search feature like XP had. Someone here suggested Agent Ransack as a search for Windows 7 and ever since then, I have used it when looking for file names, but haven't used it to find files with matching text etc.I needed to find a batch file I made in 2013 in which I tried out the Agent Ransack command line interface, and guess what I used? (click to enlarge)



You can script Agent Ransack in a batch or even from the prompt, if you are bored...

Code: [Select]C:\Batch\Ransack-Test>type My2.txt
apple
pear
dog

Code: [Select]C:\Batch\Ransack-Test>"C:\Program Files\Mythicsoft\Agent Ransack\AgentRansack.exe" -o "%cd%\ransack.rky" -oea -ofc -f "M*.txt" -c "dog AND apple" -dw

C:\Batch\Ransack-Test>type ransack.rky
C:\Batch\Ransack-Test\,My2.txt,1 KB,TXT File,23/09/2017 09:48:37,23/09/2017 09:48:37,23/09/2017 09:48:37,2,1,apple
C:\Batch\Ransack-Test\,My2.txt,1 KB,TXT File,23/09/2017 09:48:37,23/09/2017 09:48:37,23/09/2017 09:48:37,2,3,dog
Full documentation at the Agent Ransack site.

One thing I noticed is that my 2013 version of Agent Ransack defaulted to ASCII text output, whereas my current version - Release Build 867 - 2017.03.02.44979 (x64) - seems to default to UTF-8 - it started the output file with a three-byte UTF-8 Byte Order Marker (BOM) (that is, these bytes: EF BB BF) unless I expliclty specified ASCII output with the -oea option as you see above.
So, the best answer is Agent Ransack .
It is both a Visual and a command tool for finding stuff.
In Windows XP in have to stick to the 2014 version. But Windows 7 and up can use the current version.

All you people out there with Windows 7, get Agent Ransack and use in in place of the windows search tool.

Salmon Trout, great job!  Code: [Select]D:\searchtest>type g1.txt
[email protected]
D:\searchtest>type g2.txt
[email protected]
AR.bat

Code: [Select]echo off
REM Quick hack for Agent Ransack
REM Read the docs!
REM Play around!
if "%1"=="" (
echo Agent Ransack runner batch
echo usage:
echo Params 1 to 3 required, 4 is optional
echo 1 is files to search e.g. *.txt
echo 2 is text to find e.g. "foo" "foo NOT bar"
echo   Booleans are in CAPITALS
echo 3 is folder to start
echo 4 -s to recurse, omit for no recurse
echo example ar.bat "*.*" "ymail.com NOT Billy" "%cd%" "-s"
goto end
)
REM see docs for explanation of options.
REM Some of the File Locator Pro options work
REM Agent Ransack GUI will not look in zip archives,
REM CLI will, but some oddities in output
REM May still be usable. Try it & see
set ofile=%temp%\arout.txt
if exist "%ofile%" del "%ofile%"
"C:\Program Files\Mythicsoft\Agent Ransack\AgentRansack.exe" -o "%ofile%" %~4 -oea -ofc -ceb -f "%~1" -c "%~2" -d "%~3" && type "%ofile%"
:end
Code: [Select]D:\searchtest>AR.bat "*.txt" "ymail.com" "D:\searchtest"
D:\searchtest\,g1.txt,1 KB,TXT File,21/09/2017 20:46:57,23/09/2017 15:27:23,23/09/2017 15:27:23,1,1,[email protected]
D:\searchtest\,g2.txt,1 KB,TXT File,21/09/2017 19:47:39,23/09/2017 15:27:23,23/09/2017 15:27:23,1,1,[email protected]
D:\searchtest>AR.bat "*.txt" "ymail.com NOT Gordon" "D:\searchtest"
D:\searchtest\,g2.txt,1 KB,TXT File,21/09/2017 19:47:39,23/09/2017 15:27:23,23/09/2017 15:27:23,1,1,[email protected]
D:\searchtest>AR.bat "*.txt" "ymail.com NOT Billy" "D:\searchtest"
D:\searchtest\,g1.txt,1 KB,TXT File,21/09/2017 20:46:57,23/09/2017 15:27:23,23/09/2017 15:27:23,1,1,[email protected] Quote

D:\searchtest\,g1.txt,1 KB,TXT File,21/09/2017 20:46:57,23/09/2017 15:27:23,23/09/2017 15:27:23,1,1,[email protected]

Column headings

Path, Filename, Size, Type, Modified date, Created date, Last accessed, Hit Count, Line number, Line text
1180.

Solve : INSERT FLASHING OR REPEATING LINE IN FILE?

Answer»

I'm batching a series of 'Call' commands to back up critical files to multiple devices (external drives, etc) and would like to display a line saying ". . . working . . ." that repeats or flashes until a called program completes.  My users complain that because the screen shows nothing during lengthy file-backups, they're not SURE anything's happening.

Using FOR has been unsuccessful I'm guessing because my use of syntax/switches is wrong.

Thoughts? 

Toyman

Just a demo you may find helpful.

Code: [Select]echo off
setlocal enabledelayedexpansion

for /f %%a in ('copy /z "%~dpf0" nul') do set "cr=%%a"
set "busy=|/-\"
set /a n=0

::spinner
  for /l %%i in (0,1,10) do (
    set /a "n=%%i%%4"
    for /l %%n in (!n! 1 !n!) do set /p "=In Progress !busy:~%%n,1! !cr!"<nul:
    ping -n 2 127.0.0.1 >nul:
)

Good luck.  Thanks, Sidewinder.

The segment (your inserted code) had to TIME out before CONTINUING to the 'call' command.  Since the called program runs in the background, I'm not there yet.  Still have the blank screen.

I think invoking ANSI.SYS and piping the ESC code to it from the Call line might work.  ESC[5m = blinking text.

I'm not having luck with that - yet.  But your answer PROMPTED a search in the FORUM where I found a section about using ANSI.SYS.  My education continues.

I appreciate your effort.

Toyman
Wanted to say ... "Welcome Back Sidewinder" ... been a while since I saw you here  Been a while...i agree   Welcome back

1181.

Solve : file sorting by size?

Answer»

hi

Iam a new to batch programming and would LIKE to seek you help.

I have 1000's of log files (.txt) in hundreds of folders varying in size from 2kb to 30mb
my request is
 a batch file to sort files as per their sizes and move them creating a new folder
10kb
20kb
50kb
500kb
and so on ..
can this be done if so please help..

thanx
You can get a list of files in a directory like this.
Code: [Select]FOR %%G IN (*.txt) DO (
    echo %%G
)
Now the really cool thing about the FOR command is that it has modifiers for the FOR variable to get different attributes from the file.  This is listed in the help for the FOR command.
You can read the help for the FOR command by TYPING this at a cmd prompt.
Code: [Select]for /?The very LAST section of the help refers to the modifiers.
Code: [Select]In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

    %~I         - expands %I removing any surrounding quotes (")
    %~fI        - expands %I to a FULLY qualified path name
    %~dI        - expands %I to a drive letter only
    %~pI        - expands %I to a path only
    %~nI        - expands %I to a file name only
    %~xI        - expands %I to a file extension only
    %~sI        - expanded path contains short names only
    %~aI        - expands %I to file attributes of file
    %~tI        - expands %I to date/time of file
    %~zI        - expands %I to size of file
    %~$PATH:I   - searches the directories listed in the PATH
                   environment variable and expands %I to the
                   fully qualified name of the first ONE found.
                   If the environment variable name is not
                   defined or the file is not found by the
                   search, then this modifier expands to the
                   empty string

The modifiers can be combined to get compound results:

    %~dpI       - expands %I to a drive letter and path only
    %~nxI       - expands %I to a file name and extension only
    %~fsI       - expands %I to a full path name with short names only
    %~dp$PATH:I - searches the directories listed in the PATH
                   environment variable for %I and expands to the
                   drive letter and path of the first one found.
    %~ftzaI     - expands %I to a DIR like output line

In the above examples %I and PATH can be replaced by other valid
values.  The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.
So by using the ~z modifier you can get the the size of the file in bytes.
Code: [Select]FOR %%G IN (*.txt) DO (
    echo Filename is: %%G
    echo File Size is: %%~zG
)

1182.

Solve : Converting Batch script to powershell?

Answer»

Hi Guys,

I am not sure if i can post this here so please let me know; I want to try and convert this batch script into a powershell one, anyone here with experience in ISE? I am not experienced with it but i am trying to learn...

If you have questions of what the script does please let me know,

Thank you



Code: [Select]for /f %%F in (IP.txt) do (

psexec.exe \\%%F -u administrator -p PassWord msg.exe * /time:30  UPDATE - App will close in 30 seconds for NEW updates to be installed. Please stand by
timeout 30

psexec.exe \\%%F -u administrator -p PassWord  msg.exe * /time:58 now updating - Please DO NOT use the computer.
timeout 3

pskill.exe "AppProcess" \\%%F -u administrator -p PassWord
timeout 5

psexec.exe -u administrator -p PassWord  \\%%F xcopy "\\%MYIP%\Share\folder1" "\\%%F\C$\Program Files (X86)\folder1" /E /C /H /R /K /Y
timeout 5

psexec.exe \\%%F -u administrator -p PassWord  msg.exe * UPDATED! If you experience any issues please call . Thank you
)

Why is the batch file a problem? Whats the goal in having it all in powershell without the batch mechanism that calls to powershell?

Is this batch your exact batch or something copy/pasted from elsewhere as an example?

I look at this and see no problems with its use other than that the user/password is out in the open wherever this batch resides, but if on 1 computer under your control then not a problem as powershell within the batch passes authentication over network to remote systems as listed in your IP.TXT list.OBVIOUSLY those are not the real passwords......
I need to convert this to Powershell for a reason that is not your concern (:
If you cant do it then please move along.


Thanks
WOW NASTY .... Well obviously you have plans to do something illegal or malicious then cause nice people generally dont ask for illegal advice with attitude. Move along little one. 

Hiding the reason = your up to no GOOD  lol how is that illegal , all the script is doing is copying stuff between computers in one network.

I have replaced all the INFO thats sensitive info and you are commenting some ignorant *censored*. If you are not here to help then why are you even wasting your time commenting?? are you that much of a salty person? By the way if you are going to accuse someone of doing something illegal then have some proof.  edited by AllanI've edited your post. No more personal attacks please.Then make sure people don't come and post stuff like that. i'm asking for help if you don't want to then move along. no need to comment.okay, thanks for stopping by. Lot's of other sites will no doubt welcome you.

1183.

Solve : Dos command to move files that contain a particular word from source to target?

Answer»

I need to move files from source to target folder that contain in the file text a particular word, (not file name)

Give a try and change for your SETTINGS the variables keyWord, SourceFolder, TargetFolder and if you found that correct for your case, just omit the echo command before the command move
Code: [Select]echo off
Title Move files that contain a particular word from source to target
Set "KeyWord=New"
Set "SourceFolder=%userprofile%\desktop"
Set "TargetFolder=C:\NewFolder"
If not EXIST "%TargetFolder%" MD "%TargetFolder%"
for /f "delims=" %%f in ('Dir /b /s "%SourceFolder%\*.txt"') do (
find /I "%KeyWord%" "%%f" &GT;nul 2>&1 && ( echo move /y "%%f" "%TargetFolder%" )
)
pauseNicely done, and happy to give it whirl after failing with my archaic ATTEMPTS
Thank you and will report back.

1184.

Solve : Game freezing in DOS?

Answer»

Guys,

I've got a problem with Wolfenstein 3D freezing the computer when I try to play it directly in DOS.  The sound card I've been using with it is the Sound Blaster AWE64 ISA.  I am still waiting for the Sound Blaster 16 to arrive.  Do you think the game won't freeze if the Sound Blaster 16 is used?  I am only able to get it working in Windows without it freezing on me.  From what I know, the in-game MUSIC is freezing the computer when Wolfenstein 3D is loading directly in DOS.Did you configure the IRQ, DMA, and IO Addresses correctly using the SETUP program? Or if it doesn't have one (I can't remember) do you have a proper SET BLASTER line when running in MS-DOS?I do.Really ? ?
What about CTCM and AWEUTIL /s? Are you running those programs in pure DOS before running the game?His brief answer tells me he's done none of the suggestions...Turns out wolf3d has no setup program and tries to autodetect, which would have made that one impossible to have done to start with as well...Which is why you need to do the settings manually...When I last ran Wolf3D, I ran it STRAIGHT from Windows.  I will try to troubleshoot it later.  It may want IRQ5 for the SoundBlaster.  SINCE I just beat the game last Friday (finished the sixth EPISODE), I'm in no big rush currently.  I will look into the BIOS and check the AWEUTIL and CTCM and make sure they're correct in DOS.I just ran another test.  At first it froze like before.  I also tried Spear of Destiny, which did the same thing.

I booted into windows, edited the Autoexec.bat and Config.sys, removing the CD-ROM drive from them.  I have a backup folder with the CD-ROM drive in them, so I can go back to that.

When it wasn't loaded, MS-DOS had more memory.  I tried to load Wolfenstein 3D directly in DOS, and this time it didn't freeze but ran in full.

I have the following set for the sound card:
SET BLASTER=A220 I5 D1 H5 P300 E620 T6

My reason for using P300 for the midi is because the Roland SCC-1 is using port 330 for midi.  Nothing is conflicting with the SCC-1 so I have nothing to report regarding it.OK, was the CD-ROM driver being loaded into the HMA? You might try that to free up more conventional memory. (use LOADHIGH= instead of LOAD=) And lines like DOS=UMB could be  helpful for DOS-only mode as well. Of course make  sure HIMEM.SYS is loaded first.I was using LOADHIGH, BC_Programmer.  Even with that set, Wolfenstein 3D froze as it still wasn't getting the full memory it needed.Why not just play it inside DOSBox?
https://www.youtube.com/watch?v=9ECeDrM-8-w QUOTE from: Squashman on October 06, 2017, 01:15:58 PM

Why not just play it inside DOSBox?
https://www.youtube.com/watch?v=9ECeDrM-8-w

Because I prefer the way it is in real DOS.  I don't want to accidentally go to Windows.
1185.

Solve : DOS on a WYSE Thin Client?

Answer»

I installed DOS 7.1 onto a WYSE S30 thin client but it won't boot from the IDE flash. Says missing operating system despite it being correctly installed onto an active, primary partition.

The problem is with the way the BIOS waits for the OS to start booting then it disables the IDE controller. The Windows CE, WYSE Linux V6 and, XP Embedded for these is coded to work around that or re-enable the IDE.

At the bottom of this page is how someone fixed it in Tiny Core Linux. http://www.parkytowers.me.uk/thin/wyse/s10/Linux.shtml

I have a FreeDOS image someone made for the 64 megabyte module for these thin clients. It boots properly but it's all in French.

Since FreeDOS can work, how can MS-DOS be hacked to work?

I've used computers since 1983, DOS from 2.1, Windows since 3.0.Tried DOS 6.2 yet ? ?...force IDE in BIOS ? ?

Also See Here...The last stand-alone version of MS-DOS was 6.22.  If you used version 7.1 then you were using IBM's PC-DOS.  So when you say you want to get MS-DOS hacked to work, you really mean MS-DOS 6.22.There are versions of MS-DOS 7.1 floating around that are "standalone" that were effectively hacked out of Windows 9x releases. Wouldn't surprise me that they MIGHT have compatibility issues LIKE this. Quote from: patio on January 04, 2018, 11:24:25 AM

Tried DOS 6.2 yet ? ?...force IDE in BIOS ? ?

Also See Here...

All that can be changed in the WYSE Sx0 BIOS is the boot order of IDE, PXE, USB, and how much video RAM is allocated.But you stated the IDE timing out was the issue...It's not timing out, it won't allow operating systems to boot from it unless they have whatever tweak WYSE used in their Windows CE, Linux, or XP Embedded releases, or what the guy with the parkytowers site did to linux.

I just tried installing FreeDOS 1.2 Lite from a 512 meg USB drive onto a WYSE S30. Result? Failure.

It boots and launches the setup. First is says there's no fixed disk, then is says drive D: is not partitioned. So I have it partition and reboot.

Repeats this exactly the same. It's apparently blocking writes to IDE when booted from a USB that's not prepared with the WYSE utility for making an updater flash drive.So my link above was no help ? ?This may be useful. It describes how/where to get the software that is used for creating a WYSE USB Image stick. However, it looks like it wants the image file to be an RSP file, and I've not found a reliable source on what exactly that EVEN is.I just now tried a "MS-DOS 7.1" boot floppy with a USB floppy drive. I was able to wipe and repartition the DOM with FDISK then reboot and format c: /s then reboot to a DOS prompt off the DOM.

Then I tried the Lite USB install of the latest FreeDOS, same exact failure as before.

I have made Windows CE and WYSE Linux installers. First I UPDATED all three of my S30's to the last WYSE release of Windows CE, along with their BIOS.

Then I figured out how to put their Linux on one. They're locked to the OS they shipped with but knowing that WYSE offered an XP Embedded kit to upgrade any Sx0 (except the first version with soldered RAM) to S90, I figured there had to be a back door to cross-upgrade the OS. It's simple, there's a configuration file that's put on the USB stick, with a "key" that the install matches to what's embedded SOMEWHERE in the hardware. So to put WYSE Linux on an S30, just make both a WinCE and a Linux update stick then find the WinCE key and replace the Linux key with it. I'd bet all the older WYSE thin clients are done the same way. WYSE ThinOS is a different beastie. That was the S10 model and ThinOS goes into the BIOS chip. the other models may or may not have a larger BIOS chip and in any case you just can't simply download the latest/last update for it.
1186.

Solve : Batch script problem:splitting a big txt file into many 4000 lines?

Answer»

Batch script problem:splitting a BIG txt file into many 4000 lines
script:
Code: [Select]echo off
    SETLOCAL enableextensions disabledelayedexpansion

    set "nLines=4000"
    set "line=0"
    for /f %%a in ('type file.txt^|find /c /V ""') do set "fileLines=%%a"

    < "file.txt" (for /l %%a in (1 1 %fileLines%) do (
        set /p "data="
        set /a "file=1+line/%nLines%", "line+=1"
        setlocal enabledelayedexpansion
        >>"pass!file!.txt" echo(!data!
        endlocal
    ))

    endlocal
Line 4001 is not empty,LOOKS strange,here snapshot:


On my Laptop this script works perfect on my pc and my rdp NO,i don't understand why
What is generating the Text File? And curious why not just FTP the file from remote system to yourself vs splitting it into 4000 line chunks?You do not need the lines variable.  You COULD just write that line like this.
Code: [Select]set /a "file=1+(%%a-1)/nLines"Not sure what your NULL issue is.  As far as I know, batch cannot generate a null character on its own. Quote

Not sure what your NULL issue is.  As far as I know, batch cannot generate a null character on its own.

Were both on same page with that one. That's why I also asked what is generating this text file.
1187.

Solve : Copy files between specific dates?

Answer»

Hello everyone,

I am trying to play with the following code:

Code: [Select]for /F "tokens=2-4* delims=/ " %%A in ('DATE/T') do set MMDDYY=%%B-%%A-%%C

xcopy c:\source\*.* c:\dest /D:%MMDDYY%
But I can't figure out how to say I want to copy the created files from the 10th to the 15th, or from x days ago to today.

Most likely, all files between startday of X and end day of Y.

Any ideas?

Thanks for your suggestions.Robocopy has /MAXAGE and /minage options.          /MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.
          /MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.


Contents of the Robocopy Help aka robocopy/? below


Code: [Select]C:\>robocopy/?

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows

-------------------------------------------------------------------------------

  Started : Wed Nov 29 12:28:58 2017

              Usage :: ROBOCOPY source destination [file [file]...] [options]

             source :: Source Directory (drive:\path or \\server\share\path).
        destination :: Destination Dir  (drive:\path or \\server\share\path).
               file :: File(s) to copy  (names/wildcards: default is "*.*").

::
:: Copy options :
::
                 /S :: copy Subdirectories, but not empty ones.
                 /E :: copy subdirectories, including Empty ones.
             /LEV:n :: only copy the top n LEVels of the source directory tree.

                 /Z :: copy files in restartable mode.
                 /B :: copy files in Backup mode.
                /ZB :: use restartable mode; if access denied use Backup mode.
            /EFSRAW :: copy all encrypted files in EFS RAW mode.

  /COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
                       (copyflags : D=Data, A=Attributes, T=Timestamps).
                       (S=Security=NTFS ACLs, O=Owner info, U=aUditing info).

           /DCOPY:T :: COPY Directory Timestamps.

               /SEC :: copy files with SECurity (equivalent to /COPY:DATS).
           /COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).
            /NOCOPY :: COPY NO file info (useful with /PURGE).

            /SECFIX :: FIX file SECurity on all files, even skipped files.
            /TIMFIX :: FIX file TIMes on all files, even skipped files.

             /PURGE :: delete dest files/dirs that no longer exist in source.
               /MIR :: MIRror a directory tree (equivalent to /E plus /PURGE).

               /MOV :: MOVe files (delete from source after copying).
              /MOVE :: MOVE files AND dirs (delete from source after copying).

     /A+:[RASHCNET] :: add the given Attributes to copied files.
     /A-:[RASHCNET] :: remove the given Attributes from copied files.

            /CREATE :: CREATE directory tree and zero-length files only.
               /FAT :: create destination files using 8.3 FAT file names only.
               /256 :: turn off very long path (> 256 characters) support.

             /MON:n :: MONitor source; run again when more than n changes seen.
             /MOT:m :: MOnitor source; run again in m minutes Time, if changed.

      /RH:hhmm-hhmm :: Run Hours - times when new copies may be started.
                /PF :: check run hours on a Per File (not per pass) basis.

             /IPG:n :: Inter-Packet Gap (ms), to free bandwidth on slow lines.

                /SL :: copy symbolic LINKS versus the target.

            /MT[:n] :: Do multi-threaded copies with n threads (default 8).
                       n must be at least 1 and not greater than 128.
                       This option is incompatible with the /IPG and /EFSRAW opt
ions.
                       Redirect output using /LOG option for better performance.


::
:: File Selection Options :
::
                 /A :: copy only files with the Archive attribute set.
                 /M :: copy only files with the Archive attribute and reset it.
    /IA:[RASHCNETO] :: Include only files with any of the given Attributes set.
    /XA:[RASHCNETO] :: eXclude files with any of the given Attributes set.

 /XF file [file]... :: eXclude Files matching given names/paths/wildcards.
 /XD dirs [dirs]... :: eXclude Directories matching given names/paths.

                /XC :: eXclude Changed files.
                /XN :: eXclude Newer files.
                /XO :: eXclude Older files.
                /XX :: eXclude eXtra files and directories.
                /XL :: eXclude Lonely files and directories.
                /IS :: Include Same files.
                /IT :: Include Tweaked files.

             /MAX:n :: MAXimum file size - exclude files bigger than n bytes.
             /MIN:n :: MINimum file size - exclude files smaller than n bytes.

          /MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.
          /MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.
          /MAXLAD:n :: MAXimum Last Access Date - exclude files unused since n.
          /MINLAD:n :: MINimum Last Access Date - exclude files used since n.
                       (If n < 1900 then n = n days, else n = YYYYMMDD date).

                /XJ :: eXclude Junction points. (normally included by default).

               /FFT :: assume FAT File Times (2-second granularity).
               /DST :: compensate for one-hour DST time differences.

               /XJD :: eXclude Junction points for Directories.
               /XJF :: eXclude Junction points for Files.

::
:: Retry Options :
::
               /R:n :: number of Retries on failed copies: default 1 million.
               /W:n :: Wait time between retries: default is 30 seconds.

               /REG :: Save /R:n and /W:n in the Registry as default settings.

               /TBD :: wait for sharenames To Be Defined (retry error 67).

::
:: Logging Options :
::
                 /L :: List only - don't copy, timestamp or delete any files.
                 /X :: report all eXtra files, not just those selected.
                 /V :: produce Verbose output, showing skipped files.
                /TS :: include source file Time Stamps in the output.
                /FP :: include Full Pathname of files in the output.
             /BYTES :: Print sizes as bytes.

                /NS :: No Size - don't log file sizes.
                /NC :: No Class - don't log file classes.
               /NFL :: No File List - don't log file names.
               /NDL :: No Directory List - don't log directory names.

                /NP :: No Progress - don't display percentage copied.
               /ETA :: show Estimated Time of Arrival of copied files.

          /LOG:file :: output status to LOG file (overwrite existing log).
         /LOG+:file :: output status to LOG file (append to existing log).

       /UNILOG:file :: output status to LOG file as UNICODE (overwrite existing
log).
      /UNILOG+:file :: output status to LOG file as UNICODE (append to existing
log).

               /TEE :: output to console window, as well as the log file.

               /NJH :: No Job Header.
               /NJS :: No Job Summary.

           /UNICODE :: output status as UNICODE.

::
:: Job Options :
::
       /JOB:jobname :: TAKE parameters from the named JOB file.
      /SAVE:jobname :: SAVE parameters to the named job file
              /QUIT :: QUIT after processing command line (to view parameters).

              /NOSD :: NO Source Directory is specified.
              /NODD :: NO Destination Directory is specified.
                /IF :: Include the following Files.

1188.

Solve : How to return success/failure from a batch file??

Answer»

Hello,

I am new to the DOS world. Could SOMEONE please help with these questions:

How do I return 0 for SUCCESS ate the end of an MSDOS batch file?
Similarly, how do I return 1 (or other values) representing erroneous execution?

Thanks in advance!

Gaborheres an example

echo off
setlocal enabledelayedexpansion
ping 127.0.0.1
if "%errorlevel%"=="0" cls &Echo Success.
if "%errorlevel%"=="1" cls &Echo Fail
endlocal
Thanks, but that's not exactly what I had in mind. Let me try to explain it in a different way:
a.bat calls b.bat and when b.bat completes, a.bat continues with steps depending on whether b.bat succeeded or failed.

a.bat:

Code: [Select]rem some code here
call b.bat
if "%errorlevel%=="0" goto success
:failure
rem do something
goto end
:success
rem do something else
:end
What would b.bat LOOK like for a.bat to work?

Thanks again!

GaborIf one of b.bat's commands fails because of an error then it will set errorlevel to 1 and exit the batch program, returning to a.bat.

What is wrong with the code you provided below?

FB Quote from: fireballs on September 09, 2008, 04:23:57 PM

If one of b.bat's commands fails because of an error then it will set errorlevel to 1 and exit the batch program, returning to a.bat.

Not quite. Not all MS commands fail with errorlevel 1. XCOPY, for instance can fail with errorlevels 1 to 5. This type of compare ("%errorlevel%=="0") becomes dubious at best.

B.bat can use the exit statement to pass a return code (errorlevel) back to a.bat.

Quote
Quits the CMD.EXE program (command interpreter) or the current batch
script.

EXIT [/B] [exitCode]

  /B          specifies to exit the current batch script instead of
              CMD.EXE.  If executed from outside a batch script, it
              will quit CMD.EXE

  exitCode    specifies a numeric number.  if /B is specified, sets
              ERRORLEVEL that number.  If quitting CMD.EXE, sets the process
              exit code with that number.

  Quote from: Sidewinder on September 09, 2008, 06:12:06 PM
Quote from: fireballs on September 09, 2008, 04:23:57 PM
If one of b.bat's commands fails because of an error then it will set errorlevel to 1 and exit the batch program, returning to a.bat.

Not quite. Not all MS commands fail with errorlevel 1. XCOPY, for instance can fail with errorlevels 1 to 5. This type of compare ("%errorlevel%=="0") becomes dubious at best.

B.bat can use the exit statement to pass a return code (errorlevel) back to a.bat.

Quote
Quits the CMD.EXE program (command interpreter) or the current batch
script.

EXIT [/B] [exitCode]

  /B          specifies to exit the current batch script instead of
              CMD.EXE.  If executed from outside a batch script, it
              will quit CMD.EXE

  exitCode    specifies a numeric number.  if /B is specified, sets
              ERRORLEVEL that number.  If quitting CMD.EXE, sets the process
              exit code with that number.

 

yes there are instances where the errorlevel won't be 1 choice returns 254 if there's an error. exit requires that you use the same if error gtr 0 but with exit as the command

FB Quote
exit requires that you use the same if error gtr 0 but with exit as the command

Don't really understand this. I was thinking more along the line where b.bat would abort EARLY based on some condition:

b.bat
Code: [Select]if not exist c:\file.ext exit 7
if not defined userprofile exit 9
exit 0

a.bat could the query the errorlevel and proceed accordingly, which is what I interpreted the OP requested.

  Quote from: Sidewinder on September 09, 2008, 06:51:56 PM
Quote
exit requires that you use the same if error gtr 0 but with exit as the command

Don't really understand this. I was thinking more along the line where b.bat would abort early based on some condition:

b.bat
Code: [Select]if not exist c:\file.ext exit 7
if not defined userprofile exit 9
exit 0

a.bat could the query the errorlevel and proceed accordingly, which is what I interpreted the OP requested.

 

sorry i've beed drinking so my post contained several spelling mistakes, what i meant is that you'd still have to SPECIFY under what conditions to exit with a specific exit condition using the if command.

it requires a finite amount of things that could be an error. if you use Code: [Select]if errorlevel gtr 0 exit /b [1] anything over errorleve==1 would exit with exit code 1

FByou can use:
Code: [Select]&& if success
|| if fail
example:
Code: [Select]set /a var=1/0 && echo A
set /a var=1/0 || echo A Quote from: Sidewinder on September 09, 2008, 06:12:06 PM
Quote from: fireballs on September 09, 2008, 04:23:57 PM
If one of b.bat's commands fails because of an error then it will set errorlevel to 1 and exit the batch program, returning to a.bat.

Not quite. Not all MS commands fail with errorlevel 1. XCOPY, for instance can fail with errorlevels 1 to 5. This type of compare ("%errorlevel%=="0") becomes dubious at best.

B.bat can use the exit statement to pass a return code (errorlevel) back to a.bat.

Quote
Quits the CMD.EXE program (command interpreter) or the current batch
script.

EXIT [/B] [exitCode]

  /B          specifies to exit the current batch script instead of
              CMD.EXE.  If executed from outside a batch script, it
              will quit CMD.EXE

  exitCode    specifies a numeric number.  if /B is specified, sets
              ERRORLEVEL that number.  If quitting CMD.EXE, sets the process
              exit code with that number.

 

That's exactly what I was looking for!
Thanks a lot!
Works like a charm!

Gabor
C:\>A.bat
 "Hello World"
 "Call  B.bat"
"We are in B.bat."
"Return exit code from B.bat"
"errorlevel=77"
 77
Press any key to continue . . .
C:\>type A.bat
ECHO OFF

echo  "Hello World"

echo  "Call  B.bat"

Call B.bat

echo "Return exit code from B.bat"

echo "errorlevel=%errorlevel%"
echo  %errorlevel%
pause


C:\>type B.bat
REM  return exit code to Batch A.bat
ECHO OFF

echo "We are in B.bat."

exit /B  77

C:\> 


a little late to the party, methinks...

Quote
Reply #9 on: September 10, 2008, 09:45:23 AM
Quote from: grevesz on September 09, 2008, 02:31:33 PM
How do I return 0 for success ate the end of an MSDOS batch file?
Similarly, how do I return 1 (or other values) representing erroneous execution?

The most direct way is via exit /b value,

However, in Windows 8.1 at least, that doesn't support && and || in the invoking command.

To make those operators work, exit via the end of the batch file, where you place a cmd /c exit value, e.g.,

Code: [Select]echo off
setlocal
set E_FAIL=2147500037
set exit_code=%E_FAIL%

set /p a=Pretend to succeed (y/n)?
if "%a%"=="y" goto succeed

:fail
set exit_code=%E_FAIL% & goto finish

:succeed
set exit_code=0 & goto finish

:finish
cmd /c exit %exit_code%

For example, if that file is called cmd_status.bat, then you can test it with

Code: [Select]cmd_status && echo OK || echo Bah

The Topic is 6 Years old...
Don't think he'll return. Quote from: diablo416 on September 09, 2008, 03:25:36 PM
heres an example

echo off
setlocal enabledelayedexpansion
ping 127.0.0.1
if "%errorlevel%"=="0" cls &Echo Success.
if "%errorlevel%"=="1" cls &Echo Fail
endlocal

1189.

Solve : A batch file to delete files based on time created/modified?

Answer»

I am trying out some time lapse photography to capture building work over the next 18 months. Unfortunately the software I am using  cannot be scheduled so I am getting photos 24/7. I thought the simplest way to deal with this would be a daily batch file to delete the photos taken between 0000 & 0800 and 1700 & 2359. However, I can only find how to create a batch file based on the date, but not on the time. Can anyone help? Alternative solutions are also welcome. I am using Windows 8.1Are the image files themselves named with date/time or do the names follow some other scheme?
Salmon Trout may give you a batch solution but here is a powershell solution wrapped inside a batch file.

EDIT:

if your PC is setup to enable powershell scripts then run this in the folder with the images and it
should echo the del command to the screen for each image that is outside the time range shown
 - it will delete ALL files from previous days in the current directory because they are outside the time range.

Remove the echo from echo del "%%a" to make it delete the images instead of list it to the screen after you have verified that the correct files are listed.


Code: [Select]echo off
set "file=%temp%\psdaterange.ps1"

(
echo( $folderPath = '%~dp0'
echo(
echo( $date1 = Get-Date '08:00'
echo( $date2 = Get-Date '17:00'
echo(
echo( foreach( $ITEM in (Get-ChildItem -file $folderPath^) ^)
echo( {
echo( if( $item.LastWriteTime -lt $date1 -or $item.LastWriteTime -gt $date2 ^)
echo(     {
echo(         Write-Host $folderPath$item
echo(     }
echo( }
) >"%file%"

for /f "delims=" %%a in ('powershell "%file%"') do echo del "%%a"
del "%file%"

pause
I was going to finish a VBscript/batch hybrid or pure VBscript solution I was working on, but the need has suddenly evaporated, unless the OP requests it. However it has occurred to me that it is quite easy, in Windows Explorer, to delete files created in a time range by choosing Details view and then sorting in date created order, using a mouse left click to select the first file to be deleted, then extending the selection by using the SHIFT and the down arrow keys until the last file to be deleted is reached, finally pressing the DEL key. Then the files will move to the Recycle Bin and can be recovered if needed, or SHIFT + DEL will remove them forever. Of course if there are lots of folders to be treated or if there are files from many days a scripted solution might be preferred.



Your VBS solution should work where the powershell one can be a problem if powershell is not configured to run scripts, I think.

This failed in Windows 7 and worked in Windows 8.1
It's the same code as above but the temporary file is eliminated:

Code: [Select]echo off

pushd "%~dp0"
for /f "delims=" %%a in ('powershell "foreach( $item in (Get-ChildItem -file)) {if( $item.LastWriteTime -lt '08:00' -or $item.LastWriteTime -gt '17:00' ) {Write-Host $item}}"') do echo del "%~dp0%%a"
popd

pause
Quote

However it has occurred to me that it is quite easy, in Windows Explorer, to delete files created in a time range by choosing Details view and then sorting in date created order, using a mouse left click to select the first file to be deleted, then extending the selection by using the SHIFT and the down arrow keys until the last file to be deleted is reached, finally pressing the DEL key. Then the files will move to the Recycle Bin and can be recovered if needed, or SHIFT + DEL will remove them forever. Of course if there are lots of folders to be treated or if there are files from many days a scripted solution might be preferred.

Reading down the list of replies etc, I came to same idea that Salmon did with why not just sort by date and select the range to delete. However if there is a need to automate the clean up of files, then i can see using a scripted method.

In the past I had a script that would delete data from computer class lab computers in which we initially use to reimage them clean after each course was completed to make sure that they were all clean and fresh for the next class starting that next monday after completion on that friday, and instead of reimaging all the 20 systems, it was decided to just restrict the users on the lab systems to user privileges so that they couldnt install anything and very unlikely to get hit with malware, and give them a specific folder to save their work to with no other path to save to under privileges. Then instead of having to wipe entire systems clean and reimage which takes time, floods the network for about an hour or so on a Saturday and overworks the hard drives of each of the systems, its just a matter of running a quick batch routine from my system that would wipe out the data from that one folder on all 20 systems and REPLACE the pdf's in that folder with the course content for that monday depending on what they were going to be learning. Verses prior reimaging each system to make clean and delete old student data and then repopulating the system with the course content data that is local to each system for students to be able to edit and highlight SECTIONS in their PDF's etc. This could have been added to a scheduled task etc instead of a manual start of the batch that ran out to all 20 systems with the folder shared for me to wipe clean and repopulate with clean copies of the course content vs the prior content that was altered with highlighted sections and personal notations. Quote from: foxidrive on October 04, 2014, 11:08:28 AM
foreach( $item in (Get-ChildItem -file)) {if( $item.LastWriteTime -ge '08:00' -and $item.LastWriteTime -le '17:00' )

Won't that select those files whose last write time is 8 AM or after - and - earlier than or at 5 PM. i.e. the ones taken during the working day (the ones he wants to keep?)

Incidentally, Alan (if I can call you that?) I see you specify deleting images taken between midnight and 8 AM,  and between 5 PM and 11:59 PM, which is slightly ambiguous. Do you want to keep or delete files taken at 8:00 AM or 6:00 PM?
Quote from: Salmon Trout on October 04, 2014, 11:21:34 AM
Won't that select those files whose last write time is 8 AM or after - and - earlier than or at 5 PM. i.e. the ones taken during the working day (the ones he wants to keep?)

yeah, I was editing and changing stuff and lost track of what was what.

Thanks for the warning - I changed the POST above.

Quote from: DaveLembke on October 04, 2014, 11:17:19 AM
why not just sort by date and select the range to delete.

That could be done but it's not going to be as straight forward and needs to consider both 12 and 24 hour time formats (also assuming that the files in the folder are from the current date).

If we could just get a sample of %%~t from the OP, we'd know the local date/time format & it would just be something simple like if %hour% LSS 8 and if %hour% GTR 17, so if you are still there, Alan, let's hear from you!
More OP's get abducted by aliens here than any other section of the Forums... Quote from: patio on October 04, 2014, 03:40:45 PM
More OP's get abducted by aliens here than any other section of the Forums...
No officer, there is nothing in my trunk. Quote
Quote from: patio on Today at 07:40:45 AM
    More OP's get abducted by aliens here than any other section of the Forums...



Quote from: Squashman on October 04, 2014, 04:31:32 PM
No officer, there is nothing in my trunk.

Beware the ana1 probe... Quote from: foxidrive on October 04, 2014, 06:09:41 PM
Beware the ana1 probe...

Don't knock it if you haven't tried it...
Code: [Select]echo off
setlocal enabledelayedexpansion
echo Set fso = CreateObject("Scripting.FileSystemObject") > fhour.vbs
echo Set f = fso.GetFile(trim(wscript.arguments(0))) >> fhour.vbs
echo wscript.echo Hour (f.DateCreated) >> fhour.vbs
for %%A in (s:\tdate\*.jpg) do (
    for /f "delims=" %%B in ('cscript //nologo fhour.vbs %%~dpnxA') do (
        set "action=Keep  "
        if %%B lss 8  set action=Delete
        if %%B geq 17 set action=Delete
        echo !Action! %%~tA %%~dpnxA
        if "!Action!"=="Delete" del "%%~dpnxA" > nul
        )
    )
Yours is a better solution Salmon Trout, as it handles any days files.  You've done the hard work, I just polished it at the edges.

I altered your code slightly so that the batch file can reside in the same folder,
and removed the need for delayed expansion and the .vbs file is created in %temp%

echoing the date/time stamp could be confusing because the last modified time can be different, so I removed that also.

Code: [Select]echo off
:: (modified) original code by Salmon Trout - Oct 2014
:: - deletes files with creation time earlier than 08:00 and after 16:59 (on files from any day)
::

>  "%temp%\fhour.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject")
>> "%temp%\fhour.vbs" echo Set f = fso.GetFile(trim(wscript.arguments(0)))
>> "%temp%\fhour.vbs" echo wscript.echo Hour (f.DateCreated)

for %%A in ("c:\folder\*.*") do (
    for /f "delims=" %%B in ('cscript /nologo "%temp%\fhour.vbs" "%%~fA"') do (
        set "action="
        if %%B lss 8  set action=Delete
        if %%B geq 17 set action=Delete
        if /i not "%%~fA"=="%~f0" if defined action echo deleting "%%~fA" & del "%%~fA"
    )
)
pause
1190.

Solve : Batch file to unblock files copied from internet?

Answer»

Batch file to unblock files copied from internet?i found this: https://stackoverflow.com/questions/15263523/batch-file-to-unblock-files-copied-from-internet

and i use this  and reaally works: FOR %a in (*.dll *.exe *.bat *.txt *.md) do (echo.>%a:Zone.Identifier)

The problem is i have a folder: C:\Python with many files and many many diferrent types,i can't search and writte all extensions ) ,is there a command to Unlock ALL files from folder?this is my folder path and name : C:\Pythoncan do *.* covers all names and extensions. "Its going to target everything at that path no matter file name and extension type"

 FOR %a in (*.*) do (echo.>%a:Zone.Identifier)yes is exactelly what i want but can u make it run as batch script?

start cmd/ FOR %a in (*.*) do (echo.>%a:Zone.Identifier)

something like this
To run as a batch script just need to put that into notepad and then SAVE it as a filename.bat then launch the .bat file

Open notepad

copy this to it start cmd/ FOR %a in (*.*) do (echo.>%a:Zone.Identifier)

and save as MyFirstBatch.bat and launch that and it will run.not working i rceived this error message: windows cannot find 'cmd/'.Make sure you typed the name corectly,and then try again.maybe this: start cmd /k FOR %a in (*.*) do (echo.>%a:Zone.Identifier)Why are you trying to use start cmd at all.
You don't need it when running from the cmd prompt nor do you need it running in a batch file.

Also if you read the help for the FOR command you would see this very quickly.
Code: [Select]To use the FOR command in a batch PROGRAM, specify %%variable instead
of %variable.  Variable names are case sensitive, so %i is different
from %I.So your code becomes.
Code: [Select]FOR %%G in (*.*) do (echo.>%%G:Zone.Identifier)yes perfect, thank you!

1191.

Solve : Need help with a few commands from my command line class?

Answer»

I need help with the following question:

I have a directory on my c:\ called BOB. It has a lot of subdirectories and files in it.
I want to use XCOPY to copy the BOB directory to the SAVE directory on my D:\
And I want XCOPY to copy all the directories including the empty ones.
I want XCOPY to copy all the hidden and system files.
I also want XCOPY to prompt me before creating destination file.
Please show me the complete command from the c:\> to use the XCOPY command with the switches needed to accomplish the above. DO NOT add more switches than what are called for.  DO NOT use the CD command or start anywhere other than  c:\

I got this:
C:\WINDOWS\System32>xcopy c:\BOB D:\SAVE /E /H /P
Is this correct?

And this second question, I am completely lost...

On your C: drive you have a directory named HOMEWORK, in the HOMEWORK directory you have a directory named ENGLISH.  In the ENGLISH directory you have a directory named STUFF.  You have your final presentation paper in the STUFF directory named english.txt.

Windows is acting weird and you can't get into your files, and your presentation paper is due today. What are you going to do?  You realize you can bring up the command line.  You are in a hurry and you PUT your usb drive in and need to copy the english.txt file to your usb drive which is drive e:\. On drive e:\ you have a directory named PRINT.

Show me the complete command to copy the english.txt file to the PRINT directory on the e:\ and name it efinal.txt.
NOTE: Start from the c:\  and do this in ONE command on ONE line.  DO NOT use the CD command or start anywhere other than c:\




We don't do homework here...sorry.I would apply wild cards of *.* to apply to all files and file extensions.

xcopy c:\BOB\*.* D:\SAVE\*.* /E /H /P

Cant help much further as for maybe they havent covered wild cards, but thinking you will learn from PROBLEMS and sharing further problems here. For the fact that you did provide some work that is your own and arent just looking for an answer, I will help with this a little bit.

As per your second question, its quite simple to achieve, and with enough research (Google or Textbook ) you wouldnt need anyone to do it for you and would be able to assemble your own instructions based on the thousands of other examples out there that are similar. I cant think of a way to help without giving the complete answer away other than with the skills your at in your learning, you have all you need to achieve it with the correct pathing and you can target the file specific to its actual path or grab it through a selective wildcard such as *.txt to not have to type out the entire name of the file and grab all *.txt files from a target path.

Here is a listing of all the switches and what they do as well for xcopy

Quote

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\>xcopy/?
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B]
                           [/EXCLUDE:file1[+file2][+file3]...]

  source       Specifies the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /A           Copies only files with the archive attribute set,
               doesn't change the attribute.
  /M           Copies only files with the archive attribute set,
               turns off the archive attribute.
  /D:m-d-y     Copies files changed on or after the specified date.
               If no date is given, copies only those files whose
               source time is newer than the destination time.
  /EXCLUDE:file1[+file2][+file3]...
               Specifies a list of files containing strings.  Each string
               should be in a separate line in the files.  When any of the
               strings match any part of the absolute path of the file to be
               copied, that file will be excluded from being copied.  For
               example, specifying a string like \obj\ or .obj will exclude
               all files underneath the directory obj or all files with the
               .obj extension respectively.
  /P           Prompts you before creating each destination file.
  /S           Copies directories and subdirectories except empty ones.
  /E           Copies directories and subdirectories, including empty ones.
               Same as /S /E. May be used to modify /T.
  /V           Verifies the size of each new file.
  /W           Prompts you to press a key before copying.
  /C           Continues copying even if errors occur.
  /I           If destination does not exist and copying more than one file,
               assumes that destination must be a directory.
  /Q           Does not display file names while copying.
  /F           Displays full source and destination file names while copying.
  /L           Displays files that would be copied.
  /G           Allows the copying of encrypted files to destination that does
               not support encryption.
  /H           Copies hidden and system files also.
  /R           Overwrites read-only files.
  /T           Creates directory structure, but does not copy files. Does not
               include empty directories or subdirectories. /T /E includes
               empty directories and subdirectories.
  /U           Copies only files that already exist in destination.
  /K           Copies attributes. Normal Xcopy will reset read-only attributes.
  /N           Copies using the generated short names.
  /O           Copies file ownership and ACL information.
  /X           Copies file audit settings (implies /O).
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.
  /B           Copies the Symbolic Link itself versus the target of the link.
  /J           Copies using unbuffered I/O. Recommended for very large files.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

C:\>
The Internet was not created so that you could dump your homework assignments verbatim into a Q&A forum for someone to do it for you. You will never learn to do anything for yourself if that is how you want to get through life. Quote from: Squashman on November 19, 2017, 03:06:21 PM
The Internet was not created so that you could dump your homework assignments verbatim into a Q&A forum for someone to do it for you. You will never learn to do anything for yourself if that is how you want to get through life.

Ok, well I never asked for someone to do it for me. I just wanted a guide from a more personal source because the 2nd question was very specific and I still wasn't able to figure it out after reading through the my textbook and researching online. Also, I don't believe it is your place to decide how the Internet should be used. In fact, the Internet was created to ENABLE computers to connect and share information between universities, but obviously, that has changed over the YEARS. I did not know where else to turn to for help, so instead of trying to belittle me and giving me a life lesson, you could have shared another place I could have gone to for this, or not say anything at all.

Sorry if I offended anyone with this post.What is strange is why anybody would tell anybody to study DOS batch scripts for any reason. It is a skill that will die like magnetic memory bead threading.


Might as well teach students Latin.
Thinking  about it, , Latin has more promise

Image for Wikipedia. Quote from: Sooshi4u on November 19, 2017, 05:01:05 PM
I still wasn't able to figure it out after reading through the my textbook and researching online.
So you didn't read the help file?
Code: [Select]Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\Squashman>copy /?
Copies one or more files to another location.

COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B]
     [+ source [/A | /B] [+ ...]] [destination [/A | /B]]

  source       Specifies the file or files to be copied.
  /A           Indicates an ASCII text file.
  /B           Indicates a binary file.
  /D           Allow the destination file to be created decrypted
  destination  Specifies the directory and/or filename for the new file(s).
  /V           Verifies that new files are written correctly.
  /N           Uses short filename, if available, when copying a file with a
               non-8dot3 name.
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.
  /L           If the source is a symbolic link, copy the link to the target
               instead of the actual file the source link points to.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.  Default is
to prompt on overwrites unless COPY command is being executed from
within a batch script.

To append files, specify a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format).

C:\Users\Squashman>
Ignore all the command line switches for the copy command and the help file says.
Code: [Select]copy source destination
source       Specifies the file or files to be copied.
destination  Specifies the directory and/or filename for the new file(s).
So lets break that down.  Essentially copying a file you have to know the SOURCE of the file and the DESTINATION of the file.  The source and destination are clearly defined in your homework assignment.

SOURCE: On your C: drive you have a directory named HOMEWORK, in the HOMEWORK directory you have a directory named ENGLISH.  In the ENGLISH directory you have a directory named STUFF.  You have your final presentation paper in the STUFF directory named english.txt.

DESTINATION: copy the english.txt file to your usb drive which is drive e:\. On drive e:\ you have a directory named PRINT. copy the english.txt file to the PRINT directory on the e:\ and name it efinal.txt.

So tell me what your source and destinations are?
Quote from: Geek-9pm on November 19, 2017, 06:15:16 PM
What is strange is why anybody would tell anybody to study DOS batch scripts for any reason. It is a skill that will die like magnetic memory bead threading.

Might as well teach students Latin.
Thinking  about it, , Latin has more promise

Image for Wikipedia.
A) They are NOT DOS batch scripts any more.
B) Saying that is like telling a Unix admin they can't write BASH scripts anymore.
C) CMD.exe and Windows have a lot more commands to play with then DOS did.
D) My department generates $16 Million dollars a year in revenue off of the automation I design using batch files.
E)  I went to a Catholic High School.  They stopped teaching Latin at my high school in the 80's!

He closed his account... Quote from: Squashman on November 19, 2017, 07:18:31 PM

So lets break that down.  Essentially copying a file you have to know the SOURCE of the file and the DESTINATION of the file.  The source and destination are clearly defined in your homework assignment.

SOURCE: On your C: drive you have a directory named HOMEWORK, in the HOMEWORK directory you have a directory named ENGLISH.  In the ENGLISH directory you have a directory named STUFF.  You have your final presentation paper in the STUFF directory named english.txt.

DESTINATION: copy the english.txt file to your usb drive which is drive e:\. On drive e:\ you have a directory named PRINT. copy the english.txt file to the PRINT directory on the e:\ and name it efinal.txt.

So tell me what your source and destinations are?

so...
copy c:\HOMEWORK\ENGLISH\STUFF\english.txt E:\PRINT\efinal.txt ?? I'm not sure how to RENAME itC:\Save xcopy bob /s /h
1192.

Solve : Batch file to show or delete a numbered task names?

Answer»

Hi 
I need a little help to improve my NEW batch to show or delete a numbered TASK names
The code below works fine if the task name does not contains a space 
So i'm looking how can i modify it to read a task name with a space   
THANK you for any help 
Code: [Select]echo off
Title Delete Tasks with their time tasks execution by Hackoo 2017
Mode 90,30 & color 0A
:Menu
cls & echo(
echo Type the time with this format "hh:mm" to show or delete for scheduled Tasks
SET /a "count=0"
set /p "strTime="
cls & echo(
SETLOCAL EnableDelayedExpansion
for /f "tokens=1 delims= " %%a in ('schtasks /query ^| find /I "%strTime%"') do (
set /a "Count+=1"
set "TaskName[!Count!]=%%a"
)
Rem Display numbered Task Names
for /L %%i in (1,1,%Count%) do (
set "msg=[%%i] - !TaskName[%%i]!"
echo !msg!
)
echo(
Rem Asking the user if he wants to delete or not the numbered task names
echo Type the number of the task to delete !
set /p "Input="
for /L %%i in (1,1,%Count%) Do (
    If "%INPUT%" EQU "%%i" (
schtasks /delete /tn "!TaskName[%%i]!"
)
)
echo(
echo Type any key to show and delete another task !
Pause>nul
Goto MenuAnswered on DosTips Quote from: Squashman on November 09, 2017, 06:40:33 PM

Answered on DosTips
Thank you very much for your help
1193.

Solve : Batch Script- padding a “0” into script as well as few bug fixes?

Answer»

Currently there are a few problems I am experiencing with the BATCH file I created.:

1) i been trying to implement padding to the file versions from 02-09 and for it then to RESUME like 10, 11 etc... for example the file created could be called delivery_20-11-17_2.txt but i NEED it to have padding so it will be delivery_20-11-17_02.txt when it versions up. if it gets to version 10 it will need to stay like delivery_20-11-17_10.txt.

2) When a new file is created it will save it like delivery_2017-11-09_.txt. For which there is an unnecessary underscore for the first version of the file at the end of it. i need that underscore to start once the files start versioning up from version 2 and not from the very first file created.

3) In the section of the code where i have the option to name a file there is also a bug which i'm unsure on how to resolve. For example i create the file and i choose to update filename and name it "cat" it willl be saved as delivery_2017-11-09_cat_02.txt. However I want this cat file to be delivery_2017-11-09_cat.txt at first. then if i choose to update filename and name it cat again a version 2 will be created delivery_2017-11-09_cat_02.txt. which is ok.

4) when i chose the option of "update version" a file would be saved like delivery_2017-11-09__2. a double underscore appears before the version number. I need there to be only 1 underscore their. I understand that this relate to a bit of question number 2.

Here is the code below in full:

Code: [Select]echo off

:prep
cls
set filename=
set mydate=
set newname=
set version=1
For /f "tokens=1-3 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%b-%%a)
set choice=

set filename="../delivery_%mydate%_%newname%.txt"
::set filename="../delivery_%mydate%_%version%.txt"
echo %filename%
pause

:_CHECKEXIST
cls
IF EXIST %Filename% (
    GOTO _MAINMENU
) Else (
    GOTO start
)
:_MAINMENU

ECHO.
ECHO Choose on of the the following options:
ECHO 1.   Update filename
ECHO 2.   Update version
ECHO 3.   Quit
ECHO.
SET /P Choice="Enter your selection. [1,2,3]: "
IF /I "%Choice%"=="1" GOTO addname
IF /I "%Choice%"=="2" GOTO versionup
IF /I "%Choice%"=="3" (
    GOTO _END
) ELSE (
    CLS
    GOTO _MAINMENU
)
:addname
echo Enter addition to file name
set /p newname=
set filename="../delivery_%mydate%_%newname%.txt"
echo File name is now %filename%.
::set choice3 =
::set /p choice3=(y / n)

::if '%choice3%'=='' ECHO "%choice3%" is not valid please try again

::if '%choice3%'=='y' goto versionup
::if '%choice3%'=='n' goto addname


:versionup
set /A version=version+1

echo version is %version%
::FOR /F "tokens=* delims=0" %%A IN ("%Var%") DO SET Var=%%A
set filename="../delivery_%mydate%_%newname%_%version%.txt"
if EXIST "%filename%" goto :versionup 

:start


echo.

echo Choose the following:
echo 1. Directories
echo 2. Files
echo 3. quit
echo.

set /p choice=
if '%choice%'=='1' goto directory
if '%choice%'=='2' goto file
if '%choice%'=='3' goto end
cls
ECHO "%choice%" is not valid please try again
goto start


:directory
dir /ad /on /b &GT; %filename%
echo.
goto checksuccess


:file
dir /a-d /on /b > %filename%
echo.
goto checksuccess


: checksuccess
if EXIST %filename% (
    echo %filename% written SUCCESSFULLY
) else (
    echo file not written
)


:end
echo.

1194.

Solve : Coomnd to unzip a folder full of ZIP files??

Answer»

On this PC I have downloaded a bunch of ZIP files.
On at a time. Forty ZIP files.
 My fingers are getting tired after doing only a dozen  ZIP folders.

Now I would like t o unzip thing with some kind of script or batch file. The PC has Windows XP, 7 and 10. Is there an easy way to tell Windows unzip on the files in the current directory? Or should I just use a third-[ARTY program, like 7-Zip ?

Oh, forgot to mention, the site where I got the stuff might not be a safe source. So far I found a few bits of malware that were caught by Aviva. I do not intend to run any executives, the material is mostly PDF, DOC and HTML stuff.

Any suggestions welcome. 

You have 3 OS's on that PC ? ? Quote from: patio on November 07, 2017, 10:16:43 AM

You have 3 OS's on that PC ? ?
Yes, It has a 500 GB hard drive, which is more than  enough for three OS and lots of stuff I like to have at hand. I is an old refurbished dell 755 I got on eBay. I put in the 500 GB drive and installed the three OS on it.

Do you have any ideas about how to automate the ZIP extraction? Would Windows 10 do it faster, better or easier? It is rather slow in Windows XP. and I start to fall asleep.

With Zipware (free) you can select multiple Zip files in Windows Explorer, then right click the ensemble and select Zipware from the context menu & CHOOSE to unzip each archive to a separate folder named after the zip file, or all in the same folder, or somewhere else...

System Requirements

     Windows 10
     Windows 8.1
     Windows 7
     Windows Vista
     Windows XP
     Windows Server 2016
     Windows Server 2012
     Windows Server 2008
     Windows Server 2003
     Windows 32/64 bit
     Windows .NET 4.0

Web page

https://www.zipware.org/

Click to enlarge image



Salmon Trout,
Thanks, Zipware is what I need.
And it is free! Great! I can afford free. 
7-Zip also has a batch option to unzip multiple files.  My guess would be that most of the 3rd party archive tools have that ability.Thanks, I have used different zip programs before, but this is the first time I had to unzip forty folders at  one time.
The program Salmon gave does the job very well. Each zip folder had a lot of stuff inside, so I wanted to make sure it all went into the right place. The check it out, I have it do a set of five  at a time. That worked GOOD, so then I had it do all the rest.

Thanks  for responding.

If you have 7-Zip you can do the exactly same thing - extract each zip archive to a separate folder (which will be in the same folder as the archives), but you need to do 2 things

1. Make 7-Zip show its context menu when right clicking multiple zip archives:

a. Open 7-Zip
b. Choose Options
c. Choose the 7-Zip tab
d. Make sure "Integrate 7-Zip to shell context menu" is checked/ticked (it isn't in the picture)
e. Click OK




2. Use the correct context menu choice. Select one or more zip archive(s) in Windows Explorer and right click them and a 7-Zip entry is in the context menu. If you have only selected one archive, it offers to extract to a folder named for/after the archive;



If you selected more than one, the option to extract each to its own folder is rather baffingly named "Extract to "\".




Salmon Trout,
Another thanks. Good Post
I did not know you could put 7-Zip into the shell menu
That makes the  thread of greater value to others.

So, for anybody who already has 7-Zip,  follow the steps shown by Salmon Trout above.
Make sure you find the place where it says:
"Integrate 7-Zip to shell context menu"
And you will be ready to go.
You can also select that option when installing 7Zip....I have found that 7-Zip has an advantage over Zipware. If you select one or more zip archives, and then right-click and drag them into another different folder, when you let go the right mouse button, you get the context menu, and the 7-zip entry offers its options but applying to that destination folder. Zipware does not do this.

1195.

Solve : Do you really need EXIT at the end of a BAT file??

Answer»

I leave off EXIT, and the BAT file works fine.  I don't notice any problems.

Do I really need to have EXIT at the end of a BAT file?Why would you start a new Topic where noone knows what the issue is ? ?
If you start a batch script (file) from an already open command window (by typing its name and pressing ENTER), if the batch ends with EXIT, that window will close. Without an EXIT, the window will stay open.

If you start a batch by double CLICKING it in Windows Explorer, the window will close when the batch ends, whether there is an EXIT or not.

If you follow EXIT with a number, that is the exit code the script will leave behind as an errorlevel.

If you don't need any of this, you can omit EXIT.


Thanks!  When do you ever want to set an "exit code"? . . . Also, if the .BAT file ran, why would there be an error?

https://ss64.com/nt/exit.html

   exitCode   Sets the %ERRORLEVEL% to a NUMERIC number.
              If quitting CMD.EXE, set the process exit code no.Exit codes are useful for creating batch files that are expected to be CALLED by other batch files. The Exit Code can return INFORMATION that can be evaluated by the calling batch file, just as you can do with internal and external commands. Quote from: slack7639 on January 03, 2018, 11:26:44 AM

Thanks!  When do you ever want to set an "exit code"? . . . Also, if the .BAT file ran, why would there be an error?

Don't think of it as always an indication of an "error". Sometimes it is just an "exit code". Historically, going right back to MS-DOS in the Microsoft world, programs and scripts have been able to leave behind a code, that is a number, in memory, which another script or program can read. It was called "ERRORLEVEL" and the name has stuck.

Here are two simple EXAMPLE scripts. Put them both in the same folder and run test1.bat

(1) test1.bat
Code: [Select]echo off
echo Running test2.bat...
call test2.bat
echo Back from test2.bat
if %errorlevel% equ 255 echo Answer was "yes"
if %errorlevel% equ 128 echo Answer was "no"
pause
(2) test2.bat
Code: [Select]echo off
:loop
set /p a="Are you happy (answer y or n)? "
if /i "%a%"=="y" exit /B 255
if /i "%a%"=="n" exit /B 128
echo Answer y or n!
goto loop
You can catch errorlevels returned by other languages:

Put these in the same folder as each other and run test3.bat

(1) stringlen.vbs
Code: [Select]wscript.quit len(wscript.arguments(0))

(2) test3.bat
Code: [Select]echo off
:loop
set /p str="Enter a string: "
if "%str%"=="" echo String cannot be empty & goto loop
wscript stringlen.vbs %str%
echo String has %errorlevel% character(s)
pause This would be better... copes when string has spaces...

(2) test3.bat
Code: [Select]echo off
:loop
set /p str="Enter a string: "
if "%str%"=="" echo String cannot be empty & goto loop
wscript stringlen.vbs "%str%"
echo String has %errorlevel% character(s)
pause
1196.

Solve : Batch file for deleting files outside of time window?

Answer»

Hi folks,

I recently revived a thread about a script that deletes files that were created outside of a certain time window (ie before 8am and after 6pm).

I think the problem I'm having is that this script is using the "date created" criteria but the "date created" corresponds to the date that I created a copy of the file for processing, not when the picture was actually TAKEN.

Does anyone know how to modify the following code so that it uses either the "date modified" or the "date taken" criteria? I think "date taken" is metadata specific to .jpg's so that might not work in a batch script but there must be a way to use "date modified". All the "date modified" tags on my photos correspond to the time they were taken by the camera.

Thanks a ton!

Jeremy

Code: [Select]echo off
:: (modified) original code by Salmon Trout - Oct 2014
:: - deletes files with creation time earlier than 08:00 and after 16:59 (on files from any day)
::

>  "%temp%\fhour.vbs" echo Set FSO = CreateObject("Scripting.FileSystemObject")
>> "%temp%\fhour.vbs" echo Set f = fso.GetFile(trim(wscript.arguments(0)))
>> "%temp%\fhour.vbs" echo wscript.echo Hour (f.DateCreated)

for %%A in ("c:\folder\*.*") do (
    for /f "delims=" %%B in ('cscript /nologo "%temp%\fhour.vbs" "%%~fA"') do (
        set "action="
        if %%B lss 8  set action=Delete
        if %%B geq 17 set action=Delete
        if /i not "%%~fA"=="%~f0" if defined action echo deleting "%%~fA" & del "%%~fA"
    )
)
pausePerhasp tis is of some help...
https://www.ocregister.com/2010/07/21/how-to-determine-when-a-photo-was-shot/
Quote

Q. I have some old pictures, mostly JPGs, that I have copied to my wife’s PC, and the dates for the files are different on her PC than on mine. Why is that and which ones are correct? My PC is running Windows XP, and hers has Windows 7.

A. JPGs are the most common file type used by digital cameras. When we transfer the files from our cameras to our PC, either by using a card reader or by connecting the camera to our PC with a USB cable, we end up with a bunch of these JPGs. After a period of time or after they have been edited, it’s frequently difficult to determine exactly when the pictures were taken.

For some reason the engineers at Microsoft have not been consistent in how dates for JPG files are reported. The dates for other files such as Microsoft Word documents are handled more consistently. Pictures such as JPGs and other image formats are a special case since the digital cameras that we use today actually store the date that a picture was taken as part of the picture or JPG file.

There are several ways to transfer the pictures to a PC to remind us when they were shot, such as placing the date taken in the name of the folder used to house the files. Of course, that doesn’t help those of us who didn’t do this. But there are ways to determine when the pictures were taken. Before we get to some of these ways, let’s discuss how Microsoft Windows handles JPG file dates.
The above article  goes on to explain the special case of JPEG files.
Thanks for the reply Geek, sounds like "date taken" may be an option. Data can be viewed in windows explorer by "date taken".

I'm less convinced now that my problem is in fact the "date created" issue because I copied a bunch of photos (at 1pm), ran the macro, and it deleted the photos DESPITE appearing to pass the "keep" criteria of being created between 8am and 5pm.

In order to get the macro working I had to change the file path and add an action to the FOR loop. In its original version the macro simply has
Code: [Select]set "action="
and will hang up until something is added after the equals sign. I'm not sure if that's part of my problem as well. So the macro I'm currently trying to run is as follows:

Code: [Select]echo off
:: (modified) original code by Salmon Trout - Oct 2014
:: - deletes files with creation time earlier than 08:00 and after 16:59 (on files from any day)
::

>  "%temp%\fhour.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject")
>> "%temp%\fhour.vbs" echo Set f = fso.GetFile(trim(wscript.arguments(0)))
>> "%temp%\fhour.vbs" echo wscript.echo Hour (f.DateCreated)

for %%A in ("c:\349GOPRO\*.*") do (
    for /f "delims=" %%B in ('cscript /nologo "%temp%\fhour.vbs" "%%~fA"') do (
        set "action=Keep"
        if %%B lss 8  set action=Delete
        if %%B geq 18 set action=Delete
        if /i not "%%~fA"=="%~f0" if defined action echo deleting "%%~fA" & del "%%~fA"
    )
)
pause
FYI photos are being taken with Gopro Hero 3 and 4's and I'm running a couple PCs, one with windows 7 and one with windows 10.

Currently it is deleting everything regardless of date created/modified/taken. If anyone knows what my problem is I'd greatly appreciate some help. Thanks!

The set "action=" was there for a reason, as you've discovered

With each file, it unsets the variable via set "action=", then it sets that variable if the hour of the DateCreated is less than 8 or greater than 18. Since you've changed it to always set the variable, it now deletes every file.

I'd expect that what is seen as a hang may be that it is processing many files which do not meet the criteria. It will only output information when it deletes files.

Also, regarding your original notes regarding modification dates,  You can change the DateCreated line reference to this to change the date being used:

Code: [Select]>> "%temp%\fhour.vbs" echo wscript.echo Hour (f.DateLastModified)Holy crap you're right and it works!

I have been SAVED many hours of manual deleting. Thanks a ton for the response.

JeremyI suppose if you would have read the code and took the time to understand it you could have seen how obvious it was to fix.
https://ss64.com/vb/filesystemobject.html
1197.

Solve : Batch file to make folders with part of folder name and then copy files?

Answer»

Hello!

I am trying to organize a lot of folders contained within the same folder, most of them follow this standard when it COMES to the folder name:

"(code) XXX NAME (Source) XXX"
//XXX represents random text that may be present.
// The first parenthesis is not always present either.

So, for example, I have a folder NAMED "(C323) Fox (Carnivore)" within my folder "Animals" and need for the batch to take the contents within the last parenthesis and make a folder with that name (if it doesnt exist already) and move the ORIGNAL folder "(C323) Fox (Carnivore)" to the new folder "Carnivore".

I have tried looking on stackoverflow and even asking myself, since all the similar things i find are for file names instead of folder names, I cant make it work.

I noticed what I was asking is very similar to topic=152980.0 posted by doshisahil95 on this very forum, just that its a folder name and the folder name would be that of the parenthesis.

Is this at all DOABLE?

I include my failure at making my own code, just for some laughs:
Quote

echo off
setlocal enabledelayedexpansion
for %%A in (*) do (
   echo directory found  %%A
   for /D "delims=" %%B in ("%%A") do set fname=%%~nB
   for /D "delims=" %%C in ("%%A") do set fextn=%%~xC
   for /D "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 (
      echo Folder !folname! exists
   )
   echo Moving file %%A to folder !folname!
   move "%%A" "!folname!"
   )
echo Finished
pause
I have some other attempts based on other posts i've found, if they help let me know!This is the example I tested with based on your description.
Code: [Select]C:\Nature>dir /ad /s /b
C:\Nature\(C323) Fox (Carnivore)
C:\Nature\C123) Wolf (Carnivore)Using this code.
Code: [Select]echo off
FOR /D %%G IN (*) DO (
FOR /F "tokens=3 delims=()" %%H IN ("%%~G") DO (
MD "%%~H" 2>nul
move "%%~G" "%%~H"
)
)Running the batch file.
Code: [Select]C:\Nature>FolderMove.bat
        1 dir(s) moved.
        1 dir(s) moved.

C:\Nature>dir /ad /s /b
C:\Nature\Carnivore
C:\Nature\Carnivore\(C323) Fox (Carnivore)
C:\Nature\Carnivore\C123) Wolf (Carnivore)

C:\Nature>
1198.

Solve : MSDOS Freezes, Hanging?

Answer»

Hi all. New here so first of all, greeetings!

I have an old Pentium machine with a Gigabyte GA586-HX mobo that I've been working on for SEVERAL days now to have DOS/Win98 and Win 2K to dual boot with altough I keep hitting snags and stops. Currently I have DOS 7.1 with Win98 installed on top of it  on a 4GB FAT partition on an 8GB IDE drive with an Iomega Zip250. The computer has 80MB of RAM which I intend to upgrade later on, a Trident V3 PCI VGA card and a Soundblaster AWE32. The problem I keep getting is just a myriad of random freezes or hangs, mainly when loading certain software up such as Lemmings 2. It will get passed the memory check and then hang. Keyboard lights respond but nothing happens after. Space Quest 3 will load to a mouse cursor which I can move but again hangs and does nothing else. Copying  a large batch of files or just big files can sometimes cause the DOS prompt to hang however its always on certain files when you do so, copying individually works fine. In Windows I practically have no issues, just a slight delay when traversing through folders on any drive. Other than that its not had any issues. When I tried to install Windows 2K to test further, the installer would black screen after saying "Starting Windows 2000". Pressing F5 to set to Standard PC made no difference.

I've tried to test several things such as:

  • ScanDisk on all drives including surface scanning
  • Low level fat format within DOS
  • Different hard drives
  • Reinstalling all of DOS, Win98 in different orders
  • Replacing the CMOS battery and checking settings

I havent yet checked the RAM or fully checked things like the AWE32's IRQ or Address altough I know they are different to factory but I'm wondering if there is something else I should try or whether someone has suggestions? Its a shame as its for using older equipment of mine and this LEGACY isnt my speciality 

Thanks for your time! Quote
on a 4GB FAT partition

FAT16 or FAT32?

If FAT16, cluster sizes larger than 32K can cause problems in "pure" MS-DOS and for MS-DOS Applications.

If FAT32, FAT32 can cause problems in "pure" MS-DOS as well, Even if you have MS-DOS 7.1 (which I should mention isn't "legitimate"- it's a hacked release ripped out of Windows 98SE)

You can eliminate that as the possible CULPRIT but using a separate partition for MS-DOS altogether, a <2GB FAT16 partition for MS-DOS and a FAT32 partition for Windows 98.I'd run memtest86 if you can get it to boot off of a CD. 80MB RAM means you have mismatched capacity and maybe even brand and latency etc. You might find that the issues are in a RAM stick or pair of RAM sticks that dont play well with others, meaning you might be dropping your RAM to 64MB to get it to behave until you get more RAM that is compatible with already existing RAM or a new used good set of RAM for greater than 64MB.

I ran into problems like your having years ago with a 486 and 24MB RAM. I stuffed as much RAM as I could into it and come to find out with 8MB - 8MB - 4MB - 4MB sticks in the memory slots one of the 4MB sticks had and issue, so I had to DROP it to 20MB until I got two more used off of ebay 8MB sticks that were same latency as the 8MB sticks I already had to bring it to 32MB. I had where Windows 95 would behave for the most part, but games would randomly hang and crash. Not sure if this is because Windows 95 was using mainly the 8MB sticks and the games ran into the upper memory where the 4MB sticks were in slots 2 and 3 where 8MB sticks were in slots 0 and 1, if memory placement even matters in controlling where an OS loads to vs games etc. It might be that RAM is evenly used among all 4 slots vs loading up from the beginning of slot 0 working its way up to slot 3 etc. Never researched that. However more than once a troubled stick in the tail end slots seems to be detected later vs sooner which might just be coincidence or maybe memory is loaded in order from lower to upper memory address vs whatever address is next available. Quote from: BC_Programmer on January 06, 2018, 08:36:27 AM
FAT16 or FAT32?

If FAT16, cluster sizes larger than 32K can cause problems in "pure" MS-DOS and for MS-DOS Applications.

If FAT32, FAT32 can cause problems in "pure" MS-DOS as well, Even if you have MS-DOS 7.1 (which I should mention isn't "legitimate"- it's a hacked release ripped out of Windows 98SE)

You can eliminate that as the possible culprit but using a separate partition for MS-DOS altogether, a <2GB FAT16 partition for MS-DOS and a FAT32 partition for Windows 98.

That's a good point. I follow LGR on youtube and he mentions all the time about only being able to use 2GB for DOS partitions. I'll have to check the file format, I'm thinking that it might be FAT32 now.

Quote from: DaveLembke on January 06, 2018, 09:04:33 AM
I'd run memtest86 if you can get it to boot off of a CD. 80MB RAM means you have mismatched capacity and maybe even brand and latency etc. You might find that the issues are in a RAM stick or pair of RAM sticks that dont play well with others, meaning you might be dropping your RAM to 64MB to get it to behave until you get more RAM that is compatible with already existing RAM or a new used good set of RAM for greater than 64MB.

I ran into problems like your having years ago with a 486 and 24MB RAM. I stuffed as much RAM as I could into it and come to find out with 8MB - 8MB - 4MB - 4MB sticks in the memory slots one of the 4MB sticks had and issue, so I had to drop it to 20MB until I got two more used off of ebay 8MB sticks that were same latency as the 8MB sticks I already had to bring it to 32MB.

I'll INVESTIGATE that too. The memory did strike me as an odd size so might have to hold for some matched pair of SIMMs.

Thanks for the responses, will try them out!
1199.

Solve : robocopy copy and save the replaced file in different folder??

Answer»

Hi guys, I got another question. USING robocopy command to copy from one location to another. when I copy something from one location to another it will replace the file with older time stamp or file size. but how can I make so that file that is replaced, instead of being replaced/deleted that it would be SAVED to a different folder?

for example, I got 3 FOLDERS. I'm copying from folder1 a file name "file1" to folder2 which already has a file named "file1". typically the file1 in folder 2 would be replaced with file1 from folder1. but what I want to accomplish is to  have file1 from folder2 to be save to FOLDER3 when file1 from folder1 is copied to folder2.

Does this make sense?

Thank you all in advance

1200.

Solve : multiple renaming files?

Answer»

Can someone help me rename multiple files.
I have about 50 FOLDERS with SUBFOLDERS and need a batch which will rename file if it finds another file in folder
So I need script to find file exist.txt and if that file exist than script should rename not_copied.txt to copied.txt
like belov

d:\myfolder\archive\john\documents\exist.txt
d:\myfolder\archive\john\documents\today\not_copied.txt
renamed to
d:\myfolder\archive\john\documents\today\copied.txt

do nothing
d:\myfolder\archive\george\documents\
d:\myfolder\archive\george\documents\today\not_copied.txt


d:\myfolder\archive\nina\documents\exist.txt
d:\myfolder\archive\nina\documents\today\not_copied.txt
rename to
d:\myfolder\archive\nina\documents\today\copied.txt

do nothing
d:\myfolder\archive\peter\documents\
d:\myfolder\archive\peter\documents\today\not_copied.txt

do nothing
d:\myfolder\archive\gil\documents\
d:\myfolder\archive\gil\documents\today\not_copied.txt

I will run that batch in folder d:\myfolderI'm kinda wondering... are John, George, Nina, Peter, and Gil real people?
yes they are real people and they have real documentsJust kidding... under d:\myfolder\archive there could be any number of folders called [person] with a folder called \documents underneath?Questions: For each of these persons (or whatever)...
Does the \documents\today folder always exist?
Does the \documents\today folder always have a file called not_copied.txt in it?
If it does, is there never a file called copied.txt in that folder?


yes all exist.
Also exist copied.txt in some folders and that file is deleted once PER week and it is created again after some other batch is finished.If copied.txt exists already, what should happen to it? Quote from: Salmon Trout on December 22, 2018, 03:58:12 AM

If copied.txt exists already, what should happen to it?

nothing.
copied.txt should stay as it is, but not_copied.txt should rename to copied.txt
Quote from: Blisk on December 22, 2018, 06:29:40 AM
nothing.
copied.txt should stay as it is, but not_copied.txt should rename to copied.txt


Rename will fail because you cannot have two files in a folder with the same name. Quote from: Salmon Trout on December 22, 2018, 07:09:02 AM
Rename will fail because you cannot have two files in a folder with the same name.
there is no two files in folder with same name, it is only one file.Your original question seeks to do this:

Quote
d:\myfolder\archive\john\documents\today\not_copied.txt
renamed to
d:\myfolder\archive\john\documents\today\copied.txt
 

That is, not_copied.txt renamed to copied.txt in that folder.

I asked:

Quote
If copied.txt exists already, what should happen to it?

I clearly meant "if d:\myfolder\archive\john\documents\today\copied.txt already exists in that folder, what should happen to it?"

One of us is confused, which one?
if that file exist than it should leave it
if there exist not_copied.txt it should rename it if laso file exist.txt exist.You cannot have 2 files called copied.txt in the same folder.

If copied.txt already exists in the same folder, what NEW name should not_copied.txt have? And what if that new name already exists etc?

Are these really the names, or just placeholders used in your question?

I have a script which looks OK, but I shall not post it here unless you address this.

I will soon click "unnotify", so please answer if you want any more help.
Quote from: Salmon Trout on December 22, 2018, 07:31:11 AM
Your original question seeks to do this:

That is, not_copied.txt renamed to copied.txt in that folder.

I asked:

I clearly meant "if d:\myfolder\archive\john\documents\today\copied.txt already exists in that folder, what should happen to it?"

One of us is confused, which one?
Did they edit their question at some point because I see this.

d:\myfolder\archive\nina\documents\exist.txt
d:\myfolder\archive\nina\documents\today\not_copied.txt Quote from: Squashman on December 22, 2018, 10:11:06 PM
Did they edit their question at some point because I see this.

d:\myfolder\archive\nina\documents\exist.txt
d:\myfolder\archive\nina\documents\today\not_copied.txt

That was not edited; that is not the problem. The requirement appears to be this:

Quote
d:\myfolder\archive\nina\documents\exist.txt
d:\myfolder\archive\nina\documents\today\not_copied.txt
rename to
d:\myfolder\archive\nina\documents\today\copied.txt

See? Same folder for copied.txt (the desired end result) I guess this could be an error.

That is

Look in folder $NAME\documents for a file called exists.txt
    If it is found:
    Look in folder $NAME\documents\today for a file called not_copied.txt
         If that is found:
         Rename it to copied_txt

I appear to have set the cat among the pigeons by asking innocently "What happens if copied.txt already exists?".

Looking behind the CODE for a moment, I am wondering if the desired end result is to copy or move not_copied.txt to another folder as copied.txt. That is, conceptually, the names copied and not_copied clash with the idea of 'rename'. Copy duplicates a file; rename leaves it in place. The question of what to do if the desired destination file place/name already exists still remains, though.