Before I begin, I just want to say that this is not a tutorial on how to have an argument with your parent(s), girlfriend(s?), spouse(s), etc. BUT if you want a tutorial on that, please go here.
I just wanted to begin this tutorial on a light note. Please disregard the above sentence.
You may have seen arguments in my previous batch scripts, for example, the USB Raper.
Arguments all look pretty much the same. They all have 1 percent sign, and a number from 0 to 9 (or ) after it. (Some may have extra letters added in, but they're still arguments)
Here are some examples:
Copy %0 "%allusersprofile%\Start Menu\Programs\Startup\"
Echo %
MD %~dp3\Folder
Now for an explanation of each argument:
%* - All arguments (except %0)
%0 - The full path to the batch file being run. Ex. "C:\Documents and Settings\User\Desktop\Example.bat"
%1 - The first word (or grouping of words enclosed in quotes) after the batch file name.
%2 - Same as %1 except the second word or group.
%3 - You get the picture? I'm not doing the rest.
Notice how in the third example there was ~dp between the % and the 3 still makes the whole thing an argument? That's because those are called modifiers. Here is a list of all the modifiers (these can be used in regular variables and FOR loop variables as well, but I'm not covering that 😯)
In the list they use %I as an example, in reality you would replace I with whatever the argument number is. What's even better is that you can combine these modifiers to get compound results, for example:
Whenever you use a modifier, you need the ~, so you lose any surrounding quotes (which can be really useful if you need to make sure there are or aren't surrounding quotes).
Here's the catch: You can have up to 9 usable arguments at one time. But what if you need 10+? That's why the SHIFT command was created.
The shift command works under this premise: after you're done with an argument, get rid of it (yay!)
It works like this:
For example:
would shift %3 to %2, %4 to %3, etc. and leave %0 and %1 unaffected.
A good use for shift is like this:
In layman's terms, shift will cut out the word and move the rest of the words down.
Thanks for reading! If you have any trouble with arguments or the shift command, feel free to click the image in my sig and PM me.
I just wanted to begin this tutorial on a light note. Please disregard the above sentence.
You may have seen arguments in my previous batch scripts, for example, the USB Raper.
Arguments all look pretty much the same. They all have 1 percent sign, and a number from 0 to 9 (or ) after it. (Some may have extra letters added in, but they're still arguments)
Here are some examples:
Copy %0 "%allusersprofile%\Start Menu\Programs\Startup\"
Echo %
MD %~dp3\Folder
Now for an explanation of each argument:
%* - All arguments (except %0)
%0 - The full path to the batch file being run. Ex. "C:\Documents and Settings\User\Desktop\Example.bat"
%1 - The first word (or grouping of words enclosed in quotes) after the batch file name.
%2 - Same as %1 except the second word or group.
%3 - You get the picture? I'm not doing the rest.
Notice how in the third example there was ~dp between the % and the 3 still makes the whole thing an argument? That's because those are called modifiers. Here is a list of all the modifiers (these can be used in regular variables and FOR loop variables as well, but I'm not covering that 😯)
Quote: %~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
In the list they use %I as an example, in reality you would replace I with whatever the argument number is. What's even better is that you can combine these modifiers to get compound results, for example:
Quote: %~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
Whenever you use a modifier, you need the ~, so you lose any surrounding quotes (which can be really useful if you need to make sure there are or aren't surrounding quotes).
Here's the catch: You can have up to 9 usable arguments at one time. But what if you need 10+? That's why the SHIFT command was created.
The shift command works under this premise: after you're done with an argument, get rid of it (yay!)
It works like this:
Code
Shift /#For example:
Code
SHIFT /2A good use for shift is like this:
Code
@echo off
set arg1=%1
set arg2=%2
shift /2
set arg3=%2
set arg4=%3
shift /3
set arg5=%3
set arg6=%4In layman's terms, shift will cut out the word and move the rest of the words down.
Thanks for reading! If you have any trouble with arguments or the shift command, feel free to click the image in my sig and PM me.




![[Image: ed8URKg.jpg]](https://i.imgur.com/ed8URKg.jpg)
![[Image: 8vvxbk8.jpg]](https://i.imgur.com/8vvxbk8.jpg)
![[Image: chain.png]](https://i.postimg.cc/NFnfH9zY/chain.png)