Friday, May 3, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2259  / 1 Year ago, sat, march 11, 2023, 2:36:29

I have large directory with lots of files and directories on a remote Windows system where I only have FTP access.



I had to do some modifications in some of the files, so I downloaded the whole directory to run a find and replace command in files recursively.



Using Git locally, I was able to get the list of modified files. (Their is no Git on the Windows system, so I can't push/pull. Besides, I only have FTP access.)



Now I need to update the files on the Windows system. Uploading file by file manually can be frustrating as there are a lot of modified files.

Some of the files are located in subdirectories and sub-subdirectories.



For example this structure (There are a lot more files):



./
|--- file1
|--- file2
|--- dir1
| |--- file1.1
| |--- dir1.1
| |---- file1.1.1
|--- dir2
|--- file2.1
|--- file2.2
|--- file2.3


How can I copy them (or moving them is even fine) to a new location, while preserving their directory structure.

This way, in my FTP client, I would just move the whole folder. It will manage the directory structure by itself.



Keep in mind, that the subdirectories have other unmodified files in them, which I do not want to be copied.



Git gave me this list, so it did half the work:



file1
file2
dir1/file1.1
dir1/dir1.1/file1.1.1
dir2/file2.1
dir2/file2.2
dir2/file2.3

More From » command-line

 Answers
0

Interesting problem. I searched a bit, so here is another approach. When you have a file list and very much files to upload. Use wput.



apt-get install wput

cat /you/large/file/list | wput ftp:/host/ -i -


I would recommend to turn on verbose output with -v



From the man page:



-i file
--input-file=file
Reads URLs and filenames from file. ...


You can also use find to pipe filenames into wput.



find | wput ftp://host/ -i -


But, take care of shell escaped characters in your list.


[#28996] Sunday, March 12, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
elecerna

Total Points: 140
Total Questions: 121
Total Answers: 107

Location: Northern Ireland
Member since Sun, Nov 21, 2021
3 Years ago
;