Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

SET Command parameters


  • Please log in to reply
6 replies to this topic

#1 manasrrp

manasrrp

  • Members
  • 11 posts
  • OFFLINE
  •  
  • Local time:07:07 PM

Posted 24 January 2018 - 02:21 PM

I have not much idea on using parameters of set command in dos. I want to create new folder as on current date such thate it should be start with a prefix word "PNSH" then DDMMYYYY For example "PNSH25012018" .

 

I found some answer from google as like :

 

SET dirname="PNSH %date:~6,4%-%date:~0,2%-%date:~3,2%"

 

MKDIR %dirname%

 

But this create a folder as like:

 

PNSH 2018-25-01

 

Please help me change parameter of SET command so that it will create folder as :

 

"PNSH25012018"


Edited by hamluis, 24 January 2018 - 05:47 PM.
Moved from Win 7 to DOS/PDA - Hamluis.


BC AdBot (Login to Remove)

 


#2 SleepyDude

SleepyDude

  • Malware Response Team
  • 3,075 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Portugal
  • Local time:02:37 PM

Posted 24 January 2018 - 02:57 PM

Hi,

 

I will not give you the answer only a hint :wink: between the two % % is the variable that gets replaced with the value you want, move the "blocks %%", remove the dashes and space to get what you want.

 

you can temporarily disable the mkdir command using:

echo MKDIR %dirname%

and use:

echo %dirname%

to test the batch script until you get the result you want.


Edited by SleepyDude, 24 January 2018 - 03:01 PM.

• Please do not PM me asking for support. Post on the forums instead it will increases the chances of getting help for your problem by one of us.
• Posts in the Malware section that are not replied to within 4 days will be closed. PM me or a moderator to reactivate.
• Please post your final results, good or bad. We like to know! Thank you!

 
Proud graduate of GeekU and member of UNITE
___
Rui

 
 


#3 mightywiz

mightywiz

  • Members
  • 810 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:06:37 AM

Posted 24 January 2018 - 05:17 PM

SET dirname="PNSH%date:~0,2%%date:~3,2%%date:~6,4%"

 

MKDIR %dirname%



#4 manasrrp

manasrrp
  • Topic Starter

  • Members
  • 11 posts
  • OFFLINE
  •  
  • Local time:07:07 PM

Posted 25 January 2018 - 03:43 AM

Many many thanks "mightywiz " It really works what exactly I need. Thank you very much.



#5 manasrrp

manasrrp
  • Topic Starter

  • Members
  • 11 posts
  • OFFLINE
  •  
  • Local time:07:07 PM

Posted 26 January 2018 - 11:47 AM

Hi mightywiz,

 

I had tried many technique but unable to reach my goal. I want to copy files from previous date folder having same name  format to another folder name with current date having same format.

 

For example :  copy all files from PNSH25012018 to PNSH26012018 using command line.

 

Which command  is appropriate by using variable %

( 1 )   COPY

( 2 )   XCOPY

( 3 )   ROBOCOPY



#6 mightywiz

mightywiz

  • Members
  • 810 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:06:37 AM

Posted 26 January 2018 - 07:03 PM

you would use robocopy with these parameters

/MAXAGE:n : MAXimum file AGE - exclude files older than n days/date.
/MINAGE:n : MINimum file AGE - exclude files newer than n days/date.
(If n < 1900 then n = no of days, else n = YYYYMMDD date).

but this is for physical time stamps not the file names.

 

to be honest i'm probably not the one to be answering these questions, i'm not a programmer.  the 1st question was just really easy.



#7 manasrrp

manasrrp
  • Topic Starter

  • Members
  • 11 posts
  • OFFLINE
  •  
  • Local time:07:07 PM

Posted 02 February 2018 - 08:42 AM

Hi,
 
ROBOCOPY  not fulfill as per requirement  as I tried 
 
XCOPY with /D (date) switch for date calculation will meet the requirement.
 
I want to copy all files & folders from a parent source folder to destination folder of current date inside a batch script such that as below.
I had make it partially completed to create the destination folder whose name be such like pre-concatenated string "PNSH" + "current date" 
 
For Example
PNSHddmmyyyy format i.e. PNSH03022018
 
The source folder is as below same as above format
PNSHddmmyyyy format i.e. PNSH02022018
 
Help me for appropriate batch script. 
 
SET sourcedir=....\....\....\current date - 1
SET destdir=%dirname%      // as above
xcopy /D........ "%sourcedir%"  "%destdir%" /E /Y
 
  :)

Edited by manasrrp, 02 February 2018 - 09:12 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users