Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
rasil
- Posts: 31
- Joined: 23 Apr 2020 13:05
#1
Post
by rasil » 02 Dec 2020 13:03
hi,
I want to move files from a folder to where the batch file is located. I cannot simply just do
because the destination folder could be named anything or be anywhere when its in a different machine. e.g. desktop
-
rasil
- Posts: 31
- Joined: 23 Apr 2020 13:05
#2
Post
by rasil » 02 Dec 2020 13:27
just a follow up I was able to do this with this script
Code: Select all
SET src_folder=WINSCP
SET tar_folder=%cd%
for /f %%a IN ('dir "%src_folder%" /b') do move "%src_folder%\%%a" "%tar_folder%\"
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#3
Post
by aGerman » 02 Dec 2020 14:21
%cd% expands to the current working directory (without trailing backslash).
%~dp0 expands to the path of the script file (with trailing backslash).
Steffen