cmd , How to print “Folder” for TRUE and “File” for FALSE in final output .csv file while run command @isdir


How to print “Folder” for TRUE and “File” for FALSE in final output .csv file while run command @isdir

Question:

Tag: cmd

I have .bat file with the following code

forfiles /S /C "cmd /c echo @path,@IsDir" >> "%dpath%" 2>&1.

The resultant .csv file reports "True" for Directory(folders) and "False" for all non directories(file).

I would like the output to report "Folder" instead of "True", and "File" instead of "False".


Answer:

The obvious solution is to add an IF statement, but the more efficient solution is to define variables for TRUE and FALSE and let variable expansion produce the result.

setlocal
set "true=Folder"
set "false=File"
forfiles /S /C "cmd /c echo @path,%%@IsDir"%%>> "%dpath%" 2>&1.

Related:


Implementing timed input in batch file. (countdown to a minute)


windows,batch-file,cmd,countdowntimer
I am using windows 8 to write a batch file and I got stuck in implementing the timer in batch file. I want to ask input from the user and give them one minute to type their input. Once the time hit a minute then display message like 'the time...

How can I run “query session” using vb.net?


vb.net,visual-studio-2013,cmd
I would like to get the results from executing "query session" in the cmd.exe and Store them in a string variable using VB.NET. I have been searching for two days now and I cannot get to run the command, I will try to save the result once I get the...

execute method in cmd without main function


java,cmd,main
I need to execute a method in .java or .class but this class doesn't have a main function (I can't use main function because it has no return value) I must execute this method in cmd , Is there any way to resolve this problem ?

'The command line is too long' when linking .obj files in Windows command prompt


windows,maven,dll,cmd,linker
As a last step to my maven build on Windows, it tries to create a dll file by linking around 1500 object files. Looks something like this: cl.exe foo.dll (around 1500 .obj files) (couple of other statically linked libraries) The build fails with just one statement: The command line is...

execute the NETSH WLAN SHOW ALL command with pauses


batch-file,cmd
I'm creating a batch program of which one function is to show all properties of the wlan, however, when executing the command NETSH WLAN SHOW ALL all output goes by so fast half of it can't be read. I was wondering if there is a way of adding pauses during...

Win7 Batch File - Moving Subfolders(& Files) to Grand-Parent Directory


batch-file,cmd,merge,move,subdirectories
I have a somewhat complicated problem. I've downloaded an archived website from archive.org using Httrack and now I have thousands of subfolders and files I need to merge before I can rebuild it. I'm trying to write a batch file to solve the problem. But my search results never come...

How to format dir command in cmd for XP and Win 2000


windows,cmd,windows-xp,windows-2000
When I use dir command in win XP it returns all kind of info: Volume in drive C is OSDisk Volume Serial Number is AEF7-B35F Directory of C:\Users\bd250124\Desktop\test 06/11/2015 12:14 PM <DIR> . 06/11/2015 12:14 PM <DIR> .. 06/11/2015 12:14 PM 10 test01.txt 06/11/2015 12:13 PM 0 test02.txt 2 File(s)...

cmd read content from file and removing extra space in the end


cmd
In a batch file I am reading the content of a file to version parameter set /p version=<"\\10.10.20.13\Versions Control\File.txt" in File.txt the value is This is a text with an extra space in the end How can I read the content of File.txt and trim the extra space after the...

File association using CMD


file,cmd,associations
What are ways to associate file from cmd? For example,I want .txt file extension to associate with a typical program, through command prompt? what is the correct file association cmd command?

Storing the value of 'bitsadmin /getstate myDownloadJob into a variable in a batch script


windows,batch-file,cmd
I am having an issue, I am running a job using bitsadmin and I want a more detailed state of the job for the people using it. bitsadmin /getbytestotal myDownloadJob bitsadmin /getbytestransferred myDownloadJob I would like to store the result of this into a variable. I tried parsing it to...

How to pass a variable into %0 part of batch file with ftp?


windows,batch-file,cmd,ftp
I have a batch file I want to be able to call from the command line like: myBatch.bat testParam That batch file is the following: set sid=%1 C:\Windows\System32\ftp.exe -s:%0 goto done open servername username password get 'FilePath%sid%restoffilepath' targetPath\%sid%MyName.txt bye :done However, I cannot seem to get the FilePath%sid%restoffilepath part to...

Windows User Environment Variable vs System Environment Variable


windows,powershell,cmd,environment-variables
In Windows, is there any shell/Powershell command to list User Environment Variable and System Environment Variable separately. If I do - SET TEMP Windows displays the User Environment Variable instead of System variable for Temp. I am looking for shell command/switch to display these variables separately....

Windows command line - filter lines with non-zero values


windows,command-line,cmd
I have a file.data whose content is as below: 140919071513,10,0,1,0,0 140919071513,11,0,1,0,0 140919071513,12,67,1,0,0 140919071513,13,89,1,0,0 140919071513,14,0,1,0,0 140919071513,15,32,1,0,0 140919071513,16,0,1,0,0 140919071513,17,0,1,0,0 140919071513,18,78,1,0,0 140919071513,19,0,1,0,0 140919071513,20,34,1,0,0 I need to run a one-line command in Windows-DOS to get the below output: (non-zero values in 3rd column) 140919071513,12,67,1,0,0 140919071513,13,89,1,0,0 140919071513,15,32,1,0,0 140919071513,18,78,1,0,0...

cmd/DOS window opens with GUI created with py2exe


python,user-interface,cmd,py2exe,pyqt5
I have created a GUI using PyQt5. The aim of the GUI is to pass some input data (images, shapefiles etc) and to use them in softwares (GIS mostly). To launch the GIS I use the subprocess.Popen command line. I have used py2exe to create my app and my problem...

How to check and correct user input when he omit the extension .exe to kill the process?


batch-file,cmd
I have this batch to kill some process typed of course by the user and it works 5/5 when the user for example typed Calc.exe with the extension, but my issue now is to improve this batch in order to add automatically with this program if the user has omitted...

How to suppress the schtask.exe warning


cmd
When schtask is invoked on the same Task name the schtask.exe prompts to ask if the task is to be replaced as it already exists: schtasks.exe /Create /TN "Disk Space Checker" /TR "powershell.exe D:\DiskSpaceMonitor\DiskSpaceMonitor.ps1" /SC MINUTE /MO 30 How can I suppress this warning and always ask the schtask to...

cmd append to file > extra space in the end


windows,cmd
set NUMBER=0 echo 3.3.3.%NUMBER% > "file.txt" after running this command the content of file.txt is 3.3.3.0 with extra space after the 0 I would like to remove the extra space, how this can be done? EDIT I following the answer of bgoldst the extra space is gone, however now I...

Execute net user command from C#


c#,asp.net,cmd,window,window-server
I want to execute net user command from C#. Below is my code:- ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd.exe"); procStartInfo.UseShellExecute = true; procStartInfo.CreateNoWindow = true; procStartInfo.Verb = "runas"; procStartInfo.Arguments = "/env /user:" + "Administrator" + "cmd /K \"net user ABC Admin123# /add\\\""; ///command contains the command to be executed in cmd...

PYTHON subprocess cmd.exe closes after first command


python,cmd,subprocess,stdout,stdin
I am working on a python program which implements the cmd window. I am using subproccess with PIPE. If for example i write "dir" (by stdout), I use communicate() in order to get the response from the cmd and it does work. The problem is that in a while True...

Batch md command


batch-file,cmd
I'm trying to copy contents of a cd to x86 of my computer. When I run my script it says "A subdirectory or file \Navel already exists". When I navigate to my x86 folder my file isnt there. How do i fix this. cd %ProgramFiles(x86)%\ md \Navel pause ...

batch result me “echo off” instead the proper result


batch-file,cmd
I have a little problem with the next code @Echo off Title STARTING cls echo. echo Checking running services... echo. timeout /t 2 /nobreak >NUL tasklist /fi "imagename eq cmd.exe" /v | find /I /N "DATABASESERVER" >NUL if "%ERRORLEVEL%"=="1" ( cls echo. echo Database is not running, now will start!...

ProcessBuilder or Runtime.getRuntime().exec won't complete jar execution


java,xml,xslt,cmd,processbuilder
I have a jar which converts one XML to other XML format using XSLT in Java. The jar copies the output to some folder. It is working absolutely fine when am running it on command prompt but running it via Runtime.getRuntime().exec or ProcessBuilder, doesn't complete the process. Just 25 files...

Batch file to conditionally execute ifortvars.bat


windows,batch-file,cmd,fortran
I am using a make.bat file to compile my Fortran code. To compile using the ifort command, I first need to initialize the compiler by executing ifortvarsbat intel64 command where I had to setup the path variable. This works fine, however, the path keeps increasing in size and says command...

bat file script to check if string contains other string


windows,batch-file,cmd
I need to write a batch file that will check if a variable contains specific value. I tried to do the following: If "%%a"=="%%a:%pattern%" ( echo Yes ) else ( echo No ) input example: %%a="bob binson" %patern%="binson" I never get Yes printed! can anyone please tell what i missed...

Alert on operation completion in windows cmd


windows,cmd,command-prompt
Using windows cmd I have to put large programs on compilation which take large amount of time. Everytime to know whether operation is complete or not I have to check cmd again and again. I want to know whether there is way by which I can make changes to cmd...

How do I make program with c# to check to see if a word is a palindrome? [closed]


c#,visual-studio,cmd
so i'm trying to make a program (text based) that can scan a word you type into it to see if it's a palindrome or not so just a true or false outcome i'm a beginner with c# so please help me out! So far this is all i have...

Create batch script to edit host file by network connection


windows,batch-file,cmd,network-programming
I want to use this batch script to add new entries into my host file automatically by using windows batch. I want to edit host file only when i m in office. I want to say like that: if(network name=='OfficeWifi') do changes... @echo off set hostspath=%windir%\System32\drivers\etc\hosts // if(network name=='OfficeWifi') echo...

How to print iterations per second?


python,performance,loops,cmd,progress
I have a small Python script which sends POST requests to a server and gets their response. It iterates 10000 times, and I managed to print the current progress in command prompt using: code=current_requestnumber print('{0}/{1}'.format(str(code),"10000"),end="\r") at the end of each loop. Because this involves interaction with a webserver, I would...

Copying CMD output to clipboard


c#,winforms,cmd
I'm trying to copy output from a program running out of the CMD prompt to the Windows clipboard. private void button1_Click(object sender, EventArgs e) { /*Relevant Code*/ Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = String.Format("/k cd {0} && backdoor -rt -on...

adding text after prompt for input


java,input,cmd,prompt
I'm new to Java & I don't even know if what I'm trying to do is actually doable in cmd but I want to know if there's a way to ask the user for an input while displaying something at the right of the input, something like: enter weight: _...

Execute multiple command lines with output


c#,cmd,output
I want to perform some command lines to display the result after each input. Process p = new Process(); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "cmd.exe"; info.RedirectStandardInput = true; info.UseShellExecute = false; p.StartInfo = info; p.Start(); using (StreamWriter sw = p.StandardInput) { if (sw.BaseStream.CanWrite) { sw.WriteLine("ftp"); //output sw.WriteLine("open ftp.server.com");...

How to wait until my batch file is finished


c#,windows,batch-file,cmd,wait
I'm doing a program where I need to start cmd and there start up a batch file. The problem is that I'm using MyProcess.WaithForexit(); and I think it does not wait until the batch file processing is finished. It just waits until the cmd is closed. My code so far:...

Check if process indirectly resulted in an error


c#,sql-server,process,cmd
I have the following code that I'm using to open cmd and run the SQL Server setup.exe with a configuration file. ProcessStartInfo pStartInfo = new ProcessStartInfo(); pStartInfo.FileName = "cmd.exe"; pStartInfo.Arguments = "/c /q setup.exe /c /q /configurationFile=../configurationFile.ini"; pStartInfo.WorkingDirectory = installDir + @"\SQL Server Unpacked"; pStartInfo.CreateNoWindow = true; pStartInfo.WindowStyle = ProcessWindowStyle.Hidden;...

How to extract a string from the first line of a file using batch?


windows,batch-file,cmd,batch-processing
I have these files that contain a name in the first line I wish to extract. All the methods I have approach either result in error or give me nothing. An example file can be found here: https://www.dropbox.com/s/0kcgj8vr3wii33s/FORS2.2011-10-23T23_59_20.355_out.fits?dl=0 I wish to extract "PN-G013.3+01.1", which lies on the first line (column...

Recursive check files and perform zip if a particular file type exists


windows,powershell,batch-file,recursion,cmd
My Problem statement: Main Folder -SubFolder1 --1.jpg --2.jpg -SUbFolder2 --Subsubfolder ---1.jpg ---2.jpg I have this main folder which has subdirectories and at the last subdirectory, there are images. Now, what I wish to achieve is recursively check if image file(s) exists in a subdirectory If it does, zip all the...

Need to run .exe file for 7 seconds and then kill the exe while performing input and output in text files


windows,batch-file,cmd
I want to create a batch file which runs a program for 7 seconds, irrespective of the completion of execution of the other program. I also want that the program should take input and save the output in an external file. This is what I tried: start program.exe ping 1.1.1.1...

Catch result of process from exe (right click context)


batch-file,command-line,cmd,registry,right-click
I wrote following reg file inorder to delete files/folders securely. Cmd working as expected. But sometimes I would like to see result of it (I do not want to disappare of cmd window) How can I pause / wait / stop before windows disappared "D:\Desktop\_NotUse\SDelete\sdelete.exe -s -p 5 \"%1\"" /pause...

Replace the part of the path by string in specific file type in a folder


windows,batch-file,cmd
In U:\mtproject\obj\ folder and sub-folders having *.def files. I need to get those file paths and print in the command prompt. but before print I need to replace the U:\mtproject\obj\ part by E:\backupDir\DefBackup\. Here is what I tried and set objdir=U:\mtproject\obj\ set backupdir=E:\backupDir\DefBackup\ for /r %objdir% %%f in (*.def) do...

Parsing the text file line-by-line using batch script (batch file)


windows,batch-file,scripting,cmd
So, I am programming in the batch script and I came across this issue. The following code will take yourwords.txt file and parse it. The existedWord variable will have the last word of the text file. So, everytime when I run this program it will only compare the user's input...

Windows script batch to copy files from different folders to other folders


windows,batch-file,cmd
The easiest way to explain the problem is by an example. I want to do something like this: file x in /path_1/A/x copy in /path_2/A/ file x in /path_1/B/x copy in /path_2/B/ ... ... file x in /path_1/Z/x copy in /path_2/Z/ From command line with a script in Windows....

IF statement in FOR loop not working


batch-file,cmd
I am creating a batch file to initialize a portable game and run it locally on a computer for performance purposes, and another script to save the game to the portable drive when finished and check for updates. Batch File (save, update, & clear local cache) @echo off title Minecraft...

Batch file to open multiple instances of cmd and run Ruby script in each instance


ruby,windows,batch-file,cmd,watir-webdriver
I'm trying to open multiple instances of cmd up which each run a ruby script at the same time. For background into the scripts, each of these ruby scripts run watir-webdriver and spawn new browser instances. All of this should happen instantaneously. Here's what I've tried: start cmd /k cd...

CMD script Malfunctioning


windows,cmd
I have a cmd script that simply runs a windows 7 custom theme-pack (you can download it here.) The file can be downloaded here Whenever I run it, the files malfunctions (read below for a description of the malfunctioning) The file's contents echo off color a title "System Shutdown Manager"...

Node spawn cant pipe cmd commands


node.js,cmd,spawn
Hello I'm creating a plugin which uses some command line commands in order to get the process memory and cpu usage how ever altho the command works in terminal it does not when running with node. Furthermore when running with node the findstr part doesnt work at all, and because...

Disable cmd opening from GUI (PyQt)


python,user-interface,cmd,pyqt,pyqt5
I have a GUI (created with PyQt5 and py2exe). This GUI takes input data (shp, images..) and uses them as parameters in softwares (ie FME). Whenever I launch a task on a software through the GUi, a cmd opens. To launch the softwares, I use subprocess.Popen in my script with...

searching a specific word from a list of words in batch file


batch-file,cmd,scripting
I have a %list% variable which has words (see the code) and I want to search a word which ends with letter 'Y' (ignoring the case-sensitive) and which starts with the last letter of user's input. User input would be any valid word. Once I find that specific word then...

Batch File get Specific IP into Variable


cmd,ip,netsh
I am trying to select a specific IP address in a windows batchfile. This line of code works, but gets the wrong IP address: for /f "delims=: tokens=2" %%a in ('ipconfig ^| findstr /R /C:"IPv4 Address"') do (set newip=%%a) If I type this at the command line, it gets a...

npm install error not installing BrowserSync package


node.js,cmd,npm,command-prompt,browser-sync
Trying to install BrowserSync I've followed the steps to install the package through the command line, installed node.js and then I went on to install npm through the command line. Now when I try to install browser-sync with the following line npm install -g browser-sync you will see it is...

Get the PID of a Windows service by the name of the service


windows,batch-file,service,cmd,pid
Is there a way of getting the PID of a windows service with a command in a batch script by just knowing the name of the service?

Checking Blank User Input in Batch file (No Input) [duplicate]


windows,batch-file,cmd,scripting
This question already has an answer here: set /p empty answer crash 1 answer So, I am asking the user to make an selection. The point of this question is to catch if the user hit just entered without any input. My plan is to find out if the...