moving files from a subsubfolder to a folder x10000 times - directory

I have a lot of folders that need organizing that would take weeks to do by hand. I already know that the . trick will work, but then I will lose the already organized file structure. What I need is my main folder (let's call it C:\docs) that has hundreds of subfolders (folder a-j), have even more subfolders within the subfolders (which I am calling subsub folders) I don't want to lose the folder structure of folder a-j, but the folders within those folders need to be emptied to their respective subfolders.
DOCS
folder a
sub folder 1
file 1,2,3,4......
sub folder 2
file 5,6,7,8......
sub folder 3
file 9,10,11,12....
folder b
sub folder 1
file 1,2,3,4......
sub folder 2
file 5,6,7,8......
sub folder 3
file 9,10,11,12....
and so on.
INTO
DOCS
folder a
file 1,2,3,4,5,6,7,8,9,10,11,12......
folder b
file 1,2,3,4,5,6,7,8,9,10,11,12......
and so on.
Any help with this would be great. I can't even get the language right to google search my problem, because all I get is the - . trick, which again is fine but would take actual weeks to do with the number of folders that need this. Thanks in advance!

What I would do is to copy the structure with ROBOCOPY.EXE tool and save it somewhere like C:\Backup\
I would run a command DOS like this:
robocopy c:\docs*.* c:\backup\ /CREATE
This will copy only the structure of subdirectories.
type in a DOS box:
robocopy /?
to get all options

Related

WinSCP script to synchronize directories, but exclude several subdirectories

I need to write a script that synchronizes local files with a remote machine.
My file structure is:
ProjectFolder/
.git/
input/
output/
classes/
main.py
readme.md
I need to synchronize everything, but:
completely ignore .git folder
ignore files in input and output folders, but copy the folder
So far my code is:
open sftp://me:password#server -hostkey="XXXXXXXX"
option batch abort
option confirm off
synchronize remote "C:\Users\MYNAME\Documents\MY FOLDER\Python Projects\ProjectFolder" "/home/MYNAME/py_proj/ProjectFolder" -filemask="|C:\Users\MYNAME\Documents\MY FOLDER\Python Projects\ProjectFolder\.git"
close
exit
First question: it doesn't seems to work.
Second question, how to add mask for input and output folder if I have spaces in file paths?
Thanks to all in advance.
Masks for directories have to end with a slash.
To exclude files in a specific folder, use something like */folder/*
-filemask="|.git\;*/input/*;*/output/*"

UNIX: how to zip a folder that contains more folders w/o including any of the folder paths

I' m trying to zip a folder that contains some .json files plus subfolders with more .json files. I need to zip the parent folder with everything included without containing any of the parent or subfolders paths. Is there any way I can do this?
Thank you
EDIT:
I want this:
pending_provider/722c9cb2-268b-4e4a-9000-f7f65e586011-version/1d296136-ac87-424e-89c4-682a63c7b853.json (deflated 68%)
But not this:
pending_provider/722c9cb2-268b-4e4a-9000-f7f65e586011-version/ (stored 0%)
I want to avoid the "stor" compression type which only saves the folder path. I want only the "defN"
So the -j doesn't help me a lot
Thanks
If you don't want any paths at all you could use the -j option. Below is the man page entry for the option.
-j
--junk-paths
Store just the name of a saved file (junk the path), and do not store
directory names. By default, zip will store the full path (relative to
the current directory).
If you just want to exclude directories
-D
--no-dir-entries
Do not create entries in the zip archive for directories.

r copy a folder with subfolders in it

Is there a command to copy a folder including all its subfolders with files to other directory? I dont want to create the new directories and then using copy.file to move the files, Id like to make it faster.
location_folder ="path1"
new_location = ="path2"
name_folder="folder"

Manipulating multiple files with same name

I am trying to move about 1000 files that all begin with "simulation." into one directory entitled "simulations." I am using a remote server, and the files are currently in my home directory on the server. I need to move them to a separate directory because I need to, ultimately, append all the "simulation." files into one file. Is there a way to either append only the files in my home directory that begin with "simulation." or move only these files into a new directory?
Thank you.
Assuming you can change directories to the desired path on the remote server... and the simulations are located in /currentPath ... then....
cd desiredPath
mkdir simulations
mv /currentPath/simulation* simulations
(to futher answer your question... if you wanted to append all the files together, you could type cat simulation* > allSimulations.txt

Response.WriteFile to parent folder

I have built a website where all of my main menus read from the same .txt file. many of these pages are in subfolder and have to read the test.txt file from the parent folder
My webiste
test.txt
Subfoler
file reading test.txt
I was using to accomplish this but the files in the subfolder were not updating any changes I made to the test.txt
It was suggested I use <% Response.WriteFile( "test.txt" ) %>. How do I read the test.txt from a parent directory? I can not seem to get out of the subfolder.
Take a look at Server.MapPath. It lets you turn virtual URL's into physical paths. You could try Response.WriteFile(Server.MapPath("../test.txt"))

Resources