batch-file

Making a folder with incrementing number depending on existing folders with same name

我是研究僧i 提交于 2021-01-28 05:01:29
问题 I want to make a batch file which creates a folder with an incremented number when there is one already existing with the same name. For example for a folder called folder something like this: if exist folder md folder1 if exist folder1 md folder2 What I want is to make another folder with an incremented number at the end when there are already 1 or more folders with the same name (folder1, folder2, ...) and make the code shorter. 回答1: This batch code is based on your initial idea: @echo off

Return users mapped drive letter from network drive remote

半腔热情 提交于 2021-01-28 04:48:44
问题 I'm trying to find a way to retrieve the users mapped drive letter from a network drive. I've read a few posts here but they all seem to be around mapping/unmapping drives, whereas I simply need to know what drive the user has that network drive mapped to. From a command prompt I use: Net Use s: for example will give me the name of the networked drive (\servershare\file\sharename\shared), however Net Use \\servershare\file\sharename\shared just gives "The command completed successfully",

Batch file to convert text to md5sum value

倖福魔咒の 提交于 2021-01-28 04:42:22
问题 I need to create an windows "batch" file with following conditions. Convert the text to md5sum value I tried with below .bat file. But not working @echo off setlocal ENABLEDELAYEDEXPANSION set hashmd5=$(echo -n welcome1 | md5sum | cut -c 1-32); printpass=$printpass"#####MD5: echo.%%hashmd5 "\n" 回答1: Here's another version, also using certutil to generate the MD5 hash. It'll give you the MD5sum of a file or of a string argument, and can accept one line of input via the pipeline. This solution

Move folders in their own first letter directory

社会主义新天地 提交于 2021-01-28 04:14:44
问题 I use this script to move folders in their own first letter directory @echo off setlocal enabledelayedexpansion tree for /d %%i in (*) do ( set first=%%i set first=!first:~0,1! md !first! 2>nul if not "!first!" == "%%i" move "%%i" "!first!\%%i" ) tree First letter directory are generated by this script. For example if I have folders name like these Wachenfeldt - The Пламень - Чужие Von Stroheim - Lov first letter directory that are generated by this script could be W П V I don't test this

Batch File: Removing carriage return from .tsv file

喜夏-厌秋 提交于 2021-01-28 02:55:06
问题 I am trying to remove carriage return from .tsv file using batch file. This is how my .tsv file looks, the first line is a column line * **[CR] and [LF] shown in these lines are manually added to get an idea Class Name & Address Item lbs Value Pickup/Drop off Date: 23 Sep[CR][LF] Class1 Ben Coha[CR] 2305 E LA st[CR] VISIA, PA[CR] 932112-4422 Health and beauty product / cologne body wear for men 0.13 19[CR][LF] Class2 mich marce[CR] 255 rid court[CR] prince frick, PA[CR] 20442 health and

Windows batch script: Pipe text into a command line application

只谈情不闲聊 提交于 2021-01-28 02:23:14
问题 I'm writing a batch script to automate some 3D printing processes. Right now, my code looks like this: echo connect COM5 230400>3dprint.txt echo load 3dprint01.gcode>>3dprint.txt echo print>>3dprint.txt type 3dprint.txt | C:\Printrun\pronsole.exe So Pronsole is a command-line application that takes user-inputted commands (like connect, load and print above). Above, I've made the batch file create a text file and pass that into the application - except when it hits the EOF, this causes

Cross-platform scripting with Jenkins

萝らか妹 提交于 2021-01-28 00:38:40
问题 I use Jenkins a lot within our organization, for building and deploying projects. I have a set of bash scripts fine-tuned to be modular and reusable for multiple projects. These are triggered by Jenkins during deploy jobs. The problem comes when the deployment environment changes from Linux to Windows. The bash scripts are no longer an option (installing cygwin on multiple/random deployment machines is also not an option). I could rewrite all the bash scripts in batch, but that would result

Determine OneDrive Sync Status From Batch File

旧时模样 提交于 2021-01-28 00:35:38
问题 I have a OneDrive account and a Dropbox account. I use a batch file to copy my folders & files to the appropriate places. At the beginning of the batch file I use SYSINTERNALS PSSUSPEND command to suspend Dropbox. Then when OneDrive is fully synced, I can resume Dropbox using SYSINTERNALS. I currently use a delay tactic before resuming, but it would be better if I knew exactly when OneDrive was finished. I could reverse the syncs, but I don't know how to determine the sync status for Dropbox

How to deal with an em dash in a filename

旧城冷巷雨未停 提交于 2021-01-27 22:47:48
问题 On a PC with Windows 7, I'm using a simple batch script to rename some Excel files, pre-pending their parent folder name: for /f "delims=" %%i in ('dir /b /AD') do ( cd "%%i" for /f "delims=" %%j in ('dir /b *.xl*') do ren "%%~j" "%%i_%%~j" cd.. ) I noticed that some files generated an error, "System cannot find the specified file." These files all had an em dash (—) in the filename. After I changed the em dash to a regular hyphen (-), using Windows Explorer, the script worked fine on these

SQL Server 2008 R2 - sqlcmd bat file to run a batch of sql queries in folder but they are not running in order of file name

人盡茶涼 提交于 2021-01-27 20:16:32
问题 I have a bunch of written sql scripts that I have written and I was looking to run as a batch in order in a folder. After reading up I've resorted to creating a bat file which includes using the sqlcmd. For this particular set of scripts, when i run the bat it doesn't seem to run in order. I have no idea what is going on as I've tried renaming the sql scripts numerically with a prefix number in the beginning, tried using letters, and even renaming the whole script to just a number/letter