batch-file

Copy file to destination folder and keep duplicates

送分小仙女□ 提交于 2020-05-28 05:30:20
问题 How do I copy a certain file to a destination folder that already has the same file with the same name, keep both files. For eg. if a.jpg is already present in the destination folder (assume one in number), now there would two files with different names (eg. a.jpg and a(1).jpg 回答1: We can also use TIMESTAMP: @echo off for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" set

Robocopy become a endless loop

半世苍凉 提交于 2020-05-27 05:19:09
问题 I have a robocopy batch file in C:\batch. Here is the batch file: set LOG="C:\Log\robolog.txt" set START1="C:\WORK" set END1="\\fs-02\Work" Robocopy %START1% %END1% /MIR /PURGE /SEC /SECFIX /R:1 /W:5 /V /ETA /LOG:%LOG% My question is if i open cmd from the location (c:\batch) that contains this batch file and run it from there, it just runs it over and over again and never ends....and i can not even terminate the cmd .... Ctrl+C will only speed up the loop..... but if cmd start location is

CMD.exe: Get second column output to variable

…衆ロ難τιáo~ 提交于 2020-05-25 08:10:06
问题 I need the below command second column output <USERNAME> result to variables: query sessions|find "Active" >console <USERNAME> 1 Active I know the %USERNAME% OR whoami could get the current user name but this script will run using administrator account and will need to be able to capture the current active logon username. If I could select the second column of the output results and assign it to a variable.. this will be a great help. 回答1: In this case you should use FOR /F to capture the

CMD.exe: Get second column output to variable

孤街浪徒 提交于 2020-05-25 08:09:52
问题 I need the below command second column output <USERNAME> result to variables: query sessions|find "Active" >console <USERNAME> 1 Active I know the %USERNAME% OR whoami could get the current user name but this script will run using administrator account and will need to be able to capture the current active logon username. If I could select the second column of the output results and assign it to a variable.. this will be a great help. 回答1: In this case you should use FOR /F to capture the

How to get Windows CMD ECHO to echo exactly one single character?

你说的曾经没有我的故事 提交于 2020-05-25 07:10:07
问题 The (unofficial) documentation for the Windows Internal CMD ECHO shows some interesting tricks in it. However, I have not yet found a way to echo a single character . Quick note, od used below, is from a Git (or Gow) installation For instance, this echo's the 'a' with a 'windows' newline ( \r\n ): >echo a| od -A x -t x1z -v - 000000 61 0d 0a >a..< 000003 And this trick (also in the docs now) echo's nothing: ><nul (set/p _any_variable=)| od -A x -t x1z -v - 000000 So I would expect this to

batch file to list folders within a folder to one level

随声附和 提交于 2020-05-24 20:17:04
问题 I have searched and searched to no avail so apologies if the answer does exist. I am not very good with batch files so please keep this in mind. All I am after is a single batch file that will list/save to file a list of the folders within the current folder. So basically if I run this batch file within a certain folder it will output all folders (not files or sub folders, just to one level) within the folder from which the batch file was run. I assume this is probably an easy request however

How to fix RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters 1, True not updating every time

萝らか妹 提交于 2020-05-24 03:56:06
问题 I have had a look at this StackOverflow article and the same thing applies to me. Why is it that RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters 1, True does not work everytime? Is there some other way to make it work rather than repeating that until it works or is there some way to code it so that it works? .cmd , .bat and .ps1 is fine) Or is the best/only way to run it alot of times so that it works Right now my solution is to just run that multiple time until it works. Is there any

CMD batch - encode file to base 64 and trim characters and new line

南笙酒味 提交于 2020-05-23 11:45:32
问题 I'm trying to make a batch file from CMD with the following commands: Convert file to base 64 - using certutil command this is how the contents of the base 64 looks like (B64.txt): Trim the base 64 - basically, I want to remove -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- this part is done , the only thing left is trim the newline characters to make a one liner of base64, because I will be passing this to a request payload. This is what I did so far: @ECHO OFF cd /filePath

How to create folder with date and time using timestamp with robocopy command [duplicate]

跟風遠走 提交于 2020-05-17 06:54:09
问题 This question already has answers here : How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name? (27 answers) Closed last month . I want to create a folder using this Timestamp: %DATE:/=-%_%TIME::=-% My Robocopy command is : ROBOCOPY "%BUILD_SOURCESDIRECTORY%\sourcefolder\" "\\server\destination\%date:/=-%_%time::=-%" /V but it is not working, getting an error: 2020-04-07T03:53:21.7269608Z ##[error]Process completed with exit code 1.

Copy all files in his own parent

孤人 提交于 2020-05-17 06:08:22
问题 Hi everyone I need to extract multiple java files, from one directory to a root directory, but I need to preserve de first level. there are many files and many different folders, so any help is appreciated Here is an example: What I need to do is make it so that |ROOTDIRECTORY | |FOLDER1 | | SUBFOLDER | | | JA.JAVA | |FOLDER2 | | SUBFOLDER | | | AAAA.JAVA | |FOLDER3 | | SUBFOLDER | | | JAAAA.JAVA | |FOLDER4 | | SUBFOLDER | | | |SUBSUBFOLDER | | | JAV.JAVA Becomes |ROOTDIRECTORY | |FOLDER1 | |