shell


How to specify the current directory in Windows Shell?


I have the following BAT file which is intended to archive the specified folder, protect it by a password and copy the archive file to my local Dropbox folder.
"C:\Program Files\7-Zip\7z.exe" a -mx9 archive.7z "G:\This is a test\directory\with subdirectories\" -psecret -mhe=on
xcopy "G:\This is a test\directory\with subdirectories\archive.7z" "G:\My Documents\My Dropbox\" /c /d /s /e /k /y
I use 7-Zip for archiving.
Is it possible to alter the script in such a way that I can put it in any folder I choose and it does the same - archive the current folder, protect it by a password and copy the archive file to my local Dropbox folder?
Simply said, what is the command for "archive the current directory and any sub-directories"?
%CD% is your current directory. Try echo %CD% in a dos prompt to try it out.
You can specify "the current directory" simply as ., for example:
"C:\Program Files\7-Zip\7z.exe" a -mx9 archive.7z . -psecret -mhe=on
xcopy archive.7z "G:\My Documents\My Dropbox\" /c /d /s /e /k /y
It's just a more complicated case of doing something as easy as dir .
You can get the current directory path if from the script path you put this line at the top of your script file:
$CurrentDirectory = Split-Path $MyInvocation.InvocationName

Related Links

Close all open X-windows with a command in UNIX
How to search for a pattern having the special characters in awk
Stdout race condition between script and subscript
How to read sorted files using cat in shell script
Get data from multiple input file and write to another 1 file
compare 2 files in unix by key column
Searching a pattern in linux
how to parse string in to two values in shell script
Does the -?* pattern provide any advantage over -* for matching unknown command line option?
Grep IP address from variable containing file contents outside the if statement
Shell command to grep value for a key from a file
Shell script file takes partial path from parameter file
How to read file names from a txt file in cmd prompt(script) and then combine a subset of the files into a PDF file using the cmd line in windows
Creating Exclude user list for permissions- Unix
“no space” error when using shell script with ulimit stack at 32K
What is the difference between an OS and a shell?

Categories

HOME
android
sonarqube
linkedin
pagination
rdbms
google-spreadsheet
visual-studio-emulator
iis-6
computer-science
spin
google-chrome-app
openpyxl
enthought
resultset
dynatrace
internationalization
microsoft-dynamics-nav
forgot-password
soci
pyramid
digital-signature
bourbon
squashfs
react-toolbox
pimcore
displaytag
data.stackexchange.com
nstimer
weather
laravel-eloquent
android-gridview
android-maps-extensions
installscript
swagger-php
reactivekit
filesystemwatcher
verifiable-c
urlsession
numberpicker
print-css
claims
contract
apache-directory
rfc3339
dynamic-linq
nanoc
serde
manova
mongotemplate
page-replacement
amq
colorbar
git-flow
css-transforms
pybrain
objectscript
vulcanize
spring-cloud-feign
neon
dup
lean
refinerycms
cfchart
kango-framework
aurora
sapi
toran-proxy
dynatree
java-money
vigenere
evolus-pencil
uncompress
mirror
nutiteq
cross-join
ejb-2.x
viewer
big-ip
human-computer-interface
grails-plugin-rabbitmq
jammer
isqlquery
hidapi
inappsettingskit
font-awesome-4.0.0
http-status-code-410
apache-abdera
wimax
intersect
extreme-programming
mkv
pstack
wiimote
expression-blend-4
update-statement
google-floodlight
jqote
pylucene
xui
message-passing
openfaces
data-mapping
software-lifecycle
sqlobject

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App