How to zip multiple files or folders with WinSCP and automatically keep the file name part?
up vote
2
down vote
favorite
I am using WinSCP and it has the option to use custom commands remotely.
I want to zip some files and folders. WinSCP has a command that can zip a file or folder but I have to enter the name for the zip to be called.
zip -r "!?&Enter an Archive Name:?archive.zip!" !&
I would like a command that will take the name of the file and use that for the zip.
I.e. thisnewvideo.mp4
to become thisnewvideo.zip
.
I have a lot of files so typing each title will take a long time.
If it is possible I would like to be able to do multiple files at once and create a separate zip file for each file or folder keeping to original file or folder title.
It needs to be a zip file.
winscp
add a comment |
up vote
2
down vote
favorite
I am using WinSCP and it has the option to use custom commands remotely.
I want to zip some files and folders. WinSCP has a command that can zip a file or folder but I have to enter the name for the zip to be called.
zip -r "!?&Enter an Archive Name:?archive.zip!" !&
I would like a command that will take the name of the file and use that for the zip.
I.e. thisnewvideo.mp4
to become thisnewvideo.zip
.
I have a lot of files so typing each title will take a long time.
If it is possible I would like to be able to do multiple files at once and create a separate zip file for each file or folder keeping to original file or folder title.
It needs to be a zip file.
winscp
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am using WinSCP and it has the option to use custom commands remotely.
I want to zip some files and folders. WinSCP has a command that can zip a file or folder but I have to enter the name for the zip to be called.
zip -r "!?&Enter an Archive Name:?archive.zip!" !&
I would like a command that will take the name of the file and use that for the zip.
I.e. thisnewvideo.mp4
to become thisnewvideo.zip
.
I have a lot of files so typing each title will take a long time.
If it is possible I would like to be able to do multiple files at once and create a separate zip file for each file or folder keeping to original file or folder title.
It needs to be a zip file.
winscp
I am using WinSCP and it has the option to use custom commands remotely.
I want to zip some files and folders. WinSCP has a command that can zip a file or folder but I have to enter the name for the zip to be called.
zip -r "!?&Enter an Archive Name:?archive.zip!" !&
I would like a command that will take the name of the file and use that for the zip.
I.e. thisnewvideo.mp4
to become thisnewvideo.zip
.
I have a lot of files so typing each title will take a long time.
If it is possible I would like to be able to do multiple files at once and create a separate zip file for each file or folder keeping to original file or folder title.
It needs to be a zip file.
winscp
winscp
edited Jan 6 '15 at 0:28
Jawa
3,15982435
3,15982435
asked Jan 5 '15 at 23:21
Ezdub
1112
1112
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
zip -r `echo ! | sed 's/..*$/.zip/'` !
It's ok if you want multiple zip
And monster like that
ls -q !& > list_1239.txt; zip -9 "!?&FileName:?archive.zip!" $(cat list_1239.txt); rm list_1239.txt
if you want one big zip-file with custom name
add a comment |
up vote
0
down vote
WinSCP does not have a pattern or any other mechanism to extract filename without extension (or substitute the extension).
Anyway, you can use any function that the server provides to achieve the same. For example you can replace the extension using the sed
command:
echo thisnewvideo.mp4 | sed 's/..*$/.zip/'
This will output:
thisnewvideo.zip
You can merge this into the WinSCP custom command using backtick operator like:
zip -r `echo ! | sed 's/..*$/.zip/'` !
Note that the command is using the !
pattern. When you execute it for a set of selected files, it gets executed once for every file, producing one .zip
file for every source file.
For alternatives see: Extract filename and extension in Bash.
Note that I would consider better (and easier) to implement it to just append the .zip
extension (i.e. thisnewvideo.mp4.zip
) to the end of the file name, rather than substituting the extension. You would avoid name clashes, if you have two files with the same base name, just a different extension. But I do not know your constraints.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
zip -r `echo ! | sed 's/..*$/.zip/'` !
It's ok if you want multiple zip
And monster like that
ls -q !& > list_1239.txt; zip -9 "!?&FileName:?archive.zip!" $(cat list_1239.txt); rm list_1239.txt
if you want one big zip-file with custom name
add a comment |
up vote
0
down vote
zip -r `echo ! | sed 's/..*$/.zip/'` !
It's ok if you want multiple zip
And monster like that
ls -q !& > list_1239.txt; zip -9 "!?&FileName:?archive.zip!" $(cat list_1239.txt); rm list_1239.txt
if you want one big zip-file with custom name
add a comment |
up vote
0
down vote
up vote
0
down vote
zip -r `echo ! | sed 's/..*$/.zip/'` !
It's ok if you want multiple zip
And monster like that
ls -q !& > list_1239.txt; zip -9 "!?&FileName:?archive.zip!" $(cat list_1239.txt); rm list_1239.txt
if you want one big zip-file with custom name
zip -r `echo ! | sed 's/..*$/.zip/'` !
It's ok if you want multiple zip
And monster like that
ls -q !& > list_1239.txt; zip -9 "!?&FileName:?archive.zip!" $(cat list_1239.txt); rm list_1239.txt
if you want one big zip-file with custom name
edited Jul 3 '15 at 13:41
answered Jul 3 '15 at 12:55
byKos
11
11
add a comment |
add a comment |
up vote
0
down vote
WinSCP does not have a pattern or any other mechanism to extract filename without extension (or substitute the extension).
Anyway, you can use any function that the server provides to achieve the same. For example you can replace the extension using the sed
command:
echo thisnewvideo.mp4 | sed 's/..*$/.zip/'
This will output:
thisnewvideo.zip
You can merge this into the WinSCP custom command using backtick operator like:
zip -r `echo ! | sed 's/..*$/.zip/'` !
Note that the command is using the !
pattern. When you execute it for a set of selected files, it gets executed once for every file, producing one .zip
file for every source file.
For alternatives see: Extract filename and extension in Bash.
Note that I would consider better (and easier) to implement it to just append the .zip
extension (i.e. thisnewvideo.mp4.zip
) to the end of the file name, rather than substituting the extension. You would avoid name clashes, if you have two files with the same base name, just a different extension. But I do not know your constraints.
add a comment |
up vote
0
down vote
WinSCP does not have a pattern or any other mechanism to extract filename without extension (or substitute the extension).
Anyway, you can use any function that the server provides to achieve the same. For example you can replace the extension using the sed
command:
echo thisnewvideo.mp4 | sed 's/..*$/.zip/'
This will output:
thisnewvideo.zip
You can merge this into the WinSCP custom command using backtick operator like:
zip -r `echo ! | sed 's/..*$/.zip/'` !
Note that the command is using the !
pattern. When you execute it for a set of selected files, it gets executed once for every file, producing one .zip
file for every source file.
For alternatives see: Extract filename and extension in Bash.
Note that I would consider better (and easier) to implement it to just append the .zip
extension (i.e. thisnewvideo.mp4.zip
) to the end of the file name, rather than substituting the extension. You would avoid name clashes, if you have two files with the same base name, just a different extension. But I do not know your constraints.
add a comment |
up vote
0
down vote
up vote
0
down vote
WinSCP does not have a pattern or any other mechanism to extract filename without extension (or substitute the extension).
Anyway, you can use any function that the server provides to achieve the same. For example you can replace the extension using the sed
command:
echo thisnewvideo.mp4 | sed 's/..*$/.zip/'
This will output:
thisnewvideo.zip
You can merge this into the WinSCP custom command using backtick operator like:
zip -r `echo ! | sed 's/..*$/.zip/'` !
Note that the command is using the !
pattern. When you execute it for a set of selected files, it gets executed once for every file, producing one .zip
file for every source file.
For alternatives see: Extract filename and extension in Bash.
Note that I would consider better (and easier) to implement it to just append the .zip
extension (i.e. thisnewvideo.mp4.zip
) to the end of the file name, rather than substituting the extension. You would avoid name clashes, if you have two files with the same base name, just a different extension. But I do not know your constraints.
WinSCP does not have a pattern or any other mechanism to extract filename without extension (or substitute the extension).
Anyway, you can use any function that the server provides to achieve the same. For example you can replace the extension using the sed
command:
echo thisnewvideo.mp4 | sed 's/..*$/.zip/'
This will output:
thisnewvideo.zip
You can merge this into the WinSCP custom command using backtick operator like:
zip -r `echo ! | sed 's/..*$/.zip/'` !
Note that the command is using the !
pattern. When you execute it for a set of selected files, it gets executed once for every file, producing one .zip
file for every source file.
For alternatives see: Extract filename and extension in Bash.
Note that I would consider better (and easier) to implement it to just append the .zip
extension (i.e. thisnewvideo.mp4.zip
) to the end of the file name, rather than substituting the extension. You would avoid name clashes, if you have two files with the same base name, just a different extension. But I do not know your constraints.
edited May 23 '17 at 12:41
Community♦
1
1
answered Jan 6 '15 at 7:50
Martin Prikryl
10.6k43173
10.6k43173
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f861058%2fhow-to-zip-multiple-files-or-folders-with-winscp-and-automatically-keep-the-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown