Insert one and the same folder into multiple auto folders.
brucine Posted messages 24390 Registration date Status Membre Last intervention -
Hello,
I have a folder "Client Files" with 1940 subfolders named after the clients. I would like to insert 4 sub-subfolders into each subfolder without copying and pasting them 1940 times.
I would prefer not to use VBA, which I don't master.
However, I managed to create the "Client Files" folder and its subfolders using an Excel column and the cre_dossier.bat command after going through Notepad.
Maybe that's a clue?
If anyone has a simple solution...
Thank you in advance for your insights,
12 réponses
Hello,
In principle, this shouldn't create any particular issues in batch with a FOR loop that creates a subfolder in each of the folders, but I'm not sure I fully understand the request.
You want to create 4 identical, empty folders at level 3 within each of the level 2 folders?
The script would be more productive if you could provide an example of this hierarchy, with the path to the source folder called "Client Files" if I understood correctly, and made-up names for 2 clients and the 4 relevant subfolders.
Hello,
First of all, thank you for your interest in my request, and yes, I don't necessarily express myself in computer language...
That being said, for example
Rank 1 Client Files
Rank 2 Client A
Rank 3 Messaging
Rank 3 Route
Rank 3 Logistics
Rank 3 Freight
Rank 2 Client B
Rank 3 Messaging
Rank 3 Route
Rank 3 Logistics
Rank 3 Freight
Etc ...
If ranks 1 and 2 are well created in my structure, it’s the rank 3s that I would like to insert "automatically" into the Rank 2 files in order not to reproduce 1940 copies!
And indeed, they are empty.
Is that clearer?
Thank you for your help,
Hello,
I replaced the spaces with dashes and removed the acute accent; results with special characters are often unpredictable, and I assumed that the folder at rank 1 was located at the root of E:\
I suppose that the rank 2 folders already exist.
@echo off FOR /F %%a in ('dir /a:d /b /s "E:\Fiches_Clients"') DO SET CHEMIN=%%a & CALL :PROCESS GOTO EOF :PROCESS SET CHEMIN=%CHEMIN:~0,-1% MD %CHEMIN%\Messagerie MD %CHEMIN%\Route MD %CHEMIN%\Logistique MD %CHEMIN%\Affretement exit /b :EOF
Wow, THANK YOU, the root is "Y", well I can handle that ...
But, do I need to place this encoding via "Command Prompt"?
Thank you for your response and the time spent.
Text file created on desktop and named whatIwant.cmd / copy/paste executed with root change from E:\ to Y:\
But, I must be missing something, I set Y as the root, but the actual server name is:
commercial (\\192.168.2.XX)(Y:)
Is there a connection?
I can't test, I'm retired, no more PC on the network.
Even if your drive is mapped to a letter Y, you can't address it directly in the command line.
If the name of the PC to reach is "commercial", try fully qualifying the network path in the form \\commercial\ or \\192.168.2.xx\ before the target folder path on this drive.
If that doesn’t suffice, you will probably need to access this drive using a prior NET USE command, username and password at the ready:
https://ss64.com/nt/net-use.html
... Indeed, I was in the same line of thought after a few unsuccessful attempts, indeed the USB drive might be a quick solution (try it tomorrow, I don't have one on me), and what if I went directly through:
C:\Users\c.ch...\OneDrive - IMANY\Documents
I imagine that after IMANY\Documents, I should add \Client_Files? And voila?
Hello Brucine, great, the transfer and the creation of the subfolders worked.
So I have a new question to automate the following: Let's say,
I have 2 folders A & B,
A- Rank 1- "Grids"
Rank 2 - about 50 subfolders (clients) containing PRICE LIST files
B- Rank 1- The "Client_Folders" that I just created with the client names + the subfolders ...
So, rather than copying/pasting the files by client into the "Grid" folder to transfer them to the "Client_Folders" and the corresponding subfolder named after the client, I would like the transfer to happen directly.
For this, we will only take one root D:\ and of course the client names will be spelled identically from one file to another for matching.
Is this possible?
Thanks to the gray cells for the work provided!
Hello,
once again a preliminary question, I am not sure I understood the hierarchy of the ranks correctly.
It is indeed (I have included photos as pricing) to move the files from the bottom to the root of the corresponding name at the top in bulk (without creating a subfolder for Pricing) and according to this structure, to be corrected if necessary?
If that's the case, it gives this, you will replace E: with D:
Then destroy the empty source folder either manually or with a syntax
RD /S /Q
@echo off FOR /F %%a in ('dir /a:d /b /s "D:\Grilles"') DO SET GRILLES=%%a & CALL :PROCESS1 GOTO EOF :PROCESS1 SET GRILLES=%GRILLES:~0,-1% SET CLIENT=%GRILLES:~11% CALL :PROCESS2 exit /b :PROCESS2 MOVE %GRILLES%\*.* D:\Dossiers_Clients\%CLIENT% exit /b :EOF
Hello brucine,
This collaboration is great!
Yes, I think you understood my request and the hierarchy of ranks seems to match.
I assume I need to use a text file to execute this function?
However, I am clueless about: "delete the file either by using the syntax
RD /S /Q"
I will run a small-scale test during the day.
Of course, I will keep you updated.
I will conduct a small-scale test to see if it works.
See you later,
Hello,
No, it's an executable script toto.cmd, as before.
To test without any risks (simple simulation), use a second modified script as follows:
@echo off FOR /F %%a in ('dir /a:d /b /s "E:\Grilles"') DO SET GRILLES=%%a & CALL :PROCESS1 GOTO EOF :PROCESS1 SET GRILLES=%GRILLES:~0,-1% SET CLIENT=%GRILLES:~11% CALL :PROCESS2 exit /b :PROCESS2 rem MOVE %GRILLES%\*.* E:\Dossiers_Clients\%CLIENT% ROBOCOPY /L /MOV /NP /NS /NJH /NJS "%GRILLES%" "E:\Dossiers_Clients\%CLIENT%" pause exit /b :EOF The ROBOCOPY command will give you an on-screen output of the "copied" files and their location without any action.
I assume that at the end of the operation the E:\Grilles folder and its subfolders become useless; either I delete them manually or I just write before :EOF
RD /S /Q "E:\Grilles"

Ultimately, I am revisiting what I validated, as it is not quite right...
Attached is my structure of Excel FILES for pricing grids (ultimately, these are not subfolders, or the main folder would be the client's name).
The idea is to match an Excel file named for example "test 2023" with the root D:\"Grilles", in a folder named "test 2023" (same name) having the root D:\"Doccisers_Clients".
In other words, to place an file into a folder of the same name with the same root.
Is this clearer and feasible?
Thank you for all this brainstorming.
What is well conceived can be clearly stated...
We need to remove the file extension (.xls) from the folder name, and I reiterate my concerns about spaces in file (and therefore folder) names; I assume the new folder should have the complete name of the source file, not a part that could be common (2023), otherwise it will become problematic, and that the target folders do not exist beforehand.
Also, be careful if the file names are very long, we might get rejected due to the excessive length of the path to the folder and then the target file.
Before starting once more, like this?
Before:
Not sure yet.
For example, does the folder ALU AND PLASTIC 2023 already exist in Client_Folders (what a strange idea...) or do I need to create it before moving the file ALU AND PLASTIC 2023.xls from the Grids folder, which has exactly the same name?
A side question that matters and that we can't see since we can't see the extensions, we will need them to clean up, are they all xls files with an old version of Excel, not xlsx?
So to be honest, I will first change the names of the .xls files to match the client folders in the Clients_Folders.
So NO NEED TO CREATE IT.
All the client names already exist in the "Clients_Folders" folder.
And yes, old version of Excel, so .xls for the files.
If this is the final version, it's not complicated.
@echo off FOR /F %%a in ('dir /b "E:\Grilles"') DO SET FICHIER=%%a & CALL :PROCESS1 pause GOTO EOF :PROCESS1 SET FICHIER=%FICHIER:~0,-1% SET DOSSIER=%FICHIER:~0,-4% rem MOVE E:\Grilles\%FICHIER% E:\Dossiers_Clients\%DOSSIER% XCOPY /L /I /F "E:\Grilles\%FICHIER%" "E:\Dossiers_Clients\%DOSSIER%" exit /b :EOF The pause, XCOPY, and the rem prefix lines are to test on the screen without doing anything.
If the result is satisfactory, remove pause and delete the XCOPY line (or remove the rem before MOVE and put it before XCOPY).
Test carried out on a small scale.
Result: MAGIC!
I will extend it to all Files/Folders if I have time during the day.
A big THANK YOU for this support ...
"It's not complicated," says Brucine ... But still!!!
See you soon maybe ...
-
Texture issues in enshrouded
on 24 May -
Big fish games are they worth it?
on 24 May -
Saracroche: the effective french app against phone spam
on 23 May -
How to get the character µ on the android keyboard.
on 22 May -
Access issue to my "contact me" profile
on 22 May -
Windows spotlight is not working.
on 20 May -
Black screen digital camera
on 19 May -
Connecting rj45 cable with fiber
on 19 May -
Sony bravia tv red led blinks 4 times
on 19 May -
Free: associating with the freebox server in progress
on 19 May



