cmd

set variable in forfiles in for cycle

纵饮孤独 提交于 2021-02-08 09:51:45
问题 @Echo On FOR %%f IN (*.jpg) DO ( forfiles /M "%%f" /C "cmd /V:ON /c set fn=@ftime" echo %%fn%% ) pause I want to get @ftime in FOR loop, but this isn't working. Maybe there is another way to get modify time of the file? 回答1: In your method, you are setting a variable fn within the cmd instance that is opened by forfiles , but this variable is no longer available in the cmd instance that runs your script. You can use the ~t modifier of the for variable (so %%~tf in your code) to get the

wmic output to file without addtional line issue

守給你的承諾、 提交于 2021-02-08 09:36:11
问题 I've looked at all these threads and posts: Thread: https://superuser.com/questions/1082530/how-can-i-remove-the-last-blank-line-of-a-wmic-command Thread: How can I remove empty lines from wmic output? Thread: Parsing WMIC output Post: https://stackoverflow.com/a/37725658/8262102 So far and none help and most of them use findstr /r /v "^$" to do this. The issue with them all is that in my case the output contains an additional line when written to a file. My desired output to file should be:

Executing Command with “cmd” That Contains Spaces Through Git-Bash?

六眼飞鱼酱① 提交于 2021-02-08 08:46:22
问题 I'm trying to execute a command with git-bash using cmd. I need to pass the command for it to execute. The problem is I need to pass the path of the batch file into the command and it has spaces. I can't seem to be able to pass quotes to "cmd" in a way that it will understand it. cmd //C "c:\Program Files (x86)\another path\file.bat args && echo done" That will give me an error: 'C:\Program' is not recognized as an internal or external command, operable program or batch file. If I try using

Run a script via FTP connection from PowerShell

♀尐吖头ヾ 提交于 2021-02-08 08:23:33
问题 I have made a script that does a really basic task, it connects to a remote FTP site, retrieves XML files and deletes them afterward. The only problem is that in the past we lost files because they were added when the delete statement was run. open ftp.site.com username password cd Out lcd "E:\FTP\Site" mget *.XML mdel *.XML bye To prevent this from happening, we want to put a script on the FTP server ( rename-files.ps1 ). The script will rename the *.xml files to *.xml.copy . The only thing

Run a script via FTP connection from PowerShell

房东的猫 提交于 2021-02-08 08:23:10
问题 I have made a script that does a really basic task, it connects to a remote FTP site, retrieves XML files and deletes them afterward. The only problem is that in the past we lost files because they were added when the delete statement was run. open ftp.site.com username password cd Out lcd "E:\FTP\Site" mget *.XML mdel *.XML bye To prevent this from happening, we want to put a script on the FTP server ( rename-files.ps1 ). The script will rename the *.xml files to *.xml.copy . The only thing

Run a script via FTP connection from PowerShell

二次信任 提交于 2021-02-08 08:22:20
问题 I have made a script that does a really basic task, it connects to a remote FTP site, retrieves XML files and deletes them afterward. The only problem is that in the past we lost files because they were added when the delete statement was run. open ftp.site.com username password cd Out lcd "E:\FTP\Site" mget *.XML mdel *.XML bye To prevent this from happening, we want to put a script on the FTP server ( rename-files.ps1 ). The script will rename the *.xml files to *.xml.copy . The only thing

what does “..”(DotDot) mean in “cd..” command in powershell? [closed]

淺唱寂寞╮ 提交于 2021-02-08 07:30:10
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago . Improve this question I already know what it does. it simply goes one directory or folder backwards . But what's mysterious for me are those two dot. cd.. #it has the same function as popd with the difference that it changes the #current working directory if someone tell me what is

How to replace a string with a substring when there are parentheses in the string

牧云@^-^@ 提交于 2021-02-08 05:06:07
问题 I have been scratching my head for the last two days trying to put together a code that reads a folder structure and the strips off the base path of the listing. What I have so far is this: @ECHO OFF CLS SETLOCAL EnableExtensions EnableDelayedExpansion SET "StartTime=%TIME: =0%" SET "Folder=%~1" IF "%Folder:~-1%"=="\" SET "Folder=%Folder:~0,-1%" FOR %%G IN ("%Folder%") DO SET "Archive=%%~nxG" ECHO Processing %Folder%... ECHO. PUSHD "%Folder%" FOR /F "DELIMS=" %%G IN ('DIR /A:-D /B /O:N /S')

How to replace a string with a substring when there are parentheses in the string

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-08 05:05:32
问题 I have been scratching my head for the last two days trying to put together a code that reads a folder structure and the strips off the base path of the listing. What I have so far is this: @ECHO OFF CLS SETLOCAL EnableExtensions EnableDelayedExpansion SET "StartTime=%TIME: =0%" SET "Folder=%~1" IF "%Folder:~-1%"=="\" SET "Folder=%Folder:~0,-1%" FOR %%G IN ("%Folder%") DO SET "Archive=%%~nxG" ECHO Processing %Folder%... ECHO. PUSHD "%Folder%" FOR /F "DELIMS=" %%G IN ('DIR /A:-D /B /O:N /S')

Plink command results not being saved to local text file

瘦欲@ 提交于 2021-02-08 04:56:31
问题 I am calling a remote ssh through PuTTY's Plink functionality - I am able to connect and run my commands but not able to store Output into another text file - my script is as: plink ssh_hostname -m "directory\till\inputCommand.txt" -l username -pw password > "directory\where\OutputTxt_Will_Be_Saved\OutputRes.txt" Here OutputRes.txt is created, but it is completely blank. The result is shown on the command line, but not saved into OutputRes.txt (that's what I want to save on). 回答1: The command