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

How to find which users logged in in the last 30 minutes UBUNTU 16.04
Fetch data from a file
Can I automate ssh connection? ssh user#server.company.com
Oozie— java: command not found - shell action
How to execute system command with an argument that contains spaces
Why the shell doesn't write the good hour and give me the year?
shell script with dynamic variable
Trying to get files from today date and result is displaying yesterday date files as well (Unix Korn Shell)
Nagios plugin that runs at 2pm daily
remove with double-asterisk wildcards does not work [duplicate]
Zero byte output File in Unix Environment
Format data using Awk Statemnt
Passing environment variables over ssh for remote expansion
Providing input for additional authentication using Plink
Way to create multiline comments in Bash?
How do you execute a SHELL script in multiple directories without having to generate a run script

Categories

HOME
httparty
scikit-learn
nunit
hessian
jelastic
oracle-apex-5
devise
google-cloud-functions
nsbundle
permissions
cakephp-3.4
hugo
lanczos
owin
heap
ipmitool
filechannel
pybossa
atlassian
qsqlquery
esoteric-languages
aws-sdk
video-editing
imessage
mapstruct
imageresizer
exit
qliksense
monit
highstock
dapper-extensions
itunes
custom-post-type
genexus-sd
handler
exchangewebservices
paragraph
utorrent
jmockit
openwhisk
reactjs.net
least-squares
google-earth-engine
cd
timing
loading
health-monitoring
vaadin-elements
libgphoto2
facebook-pixel
lightning
spring-data-couchbase
filehandle
arules
reachability
hadoop-2.7.2
segment-io
createprocess
ellucian-scribe
assertion
oracle-spatial
morton-number
page.js
matlab-deployment
mraid
xmltype
bcache
mruby
jbake
filesplitting
crowd
cocos3d
parallel-testing
rcaller
malformedurlexception
extjs2
openargs
spring-3
bin
dtmf
ebay-lms
ui-select2
jquery-1.9
subgraph
objectquery
box2d-iphone
update-statement
inline-formset
objective-j
drupal-fivestar
isapi-extension
tui
sun
wysiwym
business-model

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