Automatically create non-existing, nested folders from upload list.

Advertisement

Registry_Editor
Guest

Automatically create non-existing, nested folders from upload list.

Good afternoon,

I'm trying to write a script to help me upload daily generated content to my server.

We're talking sometimes thousands of individual files each day, arranged like this:

example.com/docs/1/1/2/4/1/2/1/abc.txt
example.com/docs/1/2/2/3/1/3/1/def.txt
example.com/docs/1/1/1/2/3/2/1/4/1/ghi.txt
example.com/docs/1/3/2/1/1/2/3/3/2/3/1/1/jkl.txt


Mostly the folders already exist, however each time the files are generated there is the possibility for additional folders also to be generated. So I need my script to create the folder for each file if it does not already exist.

I made the foolish assumption that

put "C:\files\1\1\2\4\1\2\1\abc.txt" "example.com/docs/1/1/2/4/1/2/1/abc.txt"

would create any directory that didn't already exist and then upload the file to it. I don't see why this is not possible?

To recursively scan each directory to discover if a particular location already exists coupled with the requisite string manipulation to create said folders is starting to sound like an awful lot of work for what should surely be a simple, automatic operation.

Many thanks in advance,

RegEd

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Automatically create non-existing, nested folders from upload list.

Cannot you use synchronization like this?

synchronize remote "C:\files\*" "/docs/"

Reply with quote

Registry_Editor
Guest

Re: Automatically create non-existing, nested folders from upload list.

martin wrote:

Cannot you use synchronization like this?

synchronize remote "C:\files\*" "/docs/"

Hi Martin, thanks for the response.

I currently do use the synchronize function but because the amount of files and folders is so large this takes a very long time (1-2 hours every day) and puts unnecessary load on the server. The file generator outputs a list of modified files each time it runs so I am trying to switch over to just uploading the modified files, rather than having to run synchronize for two hours every day.

Kind regards,

RegEd

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Automatically create non-existing, nested folders from upload list.

OK, I see.

Though there's no other solution.

Either create the folders, or use the synchronization.

Reply with quote

Advertisement

You can post new topics in this forum