I would like to ask you guys if you could know a way to move a sh*tload of folders up in my tree.
Basically, I have a main folder where it contains a lot of subfolders. Each of these either:
-Contains subsubfolders themselves (in which case I would like to take these subsubfolders and put them in my main folder.
-Contains only files and no folders inside (in which case I would like to not touch them).
Could this be possible to write a batch file or any script that moves the one needed while not touching the ones without folders?
Related
I have a folder that has around 400 subfolders each with ONE .jpeg file in them. I need to get all the pictures into 1 new folder using SSIS, everything is on my local (no connecting through different servers or DBs) just subfolders to one folder so that I can pull out those images without going one by one into each subfolder.
I would create 3 variables, all of type String. CurrentFile, FolderBase, FolderOutput.
FolderBase is going to be where we start searching i.e. C:\ssisdata
FolderOutput is where we are going to move any .jpg files that we find rooted under FolderBase.
Use a Foreach File Enumerator (sample How to import text files with the same name and schema but different directories into database?) configured to process subfolders looking for *.jpg. Map the first element on the Variable tab to be our CurrentFile. Map the Enumerator to start in FolderBase. For extra flexibility, create an additional variable to hold the file mask *.jpg.
Run the package. It should quickly zip through all the folders finding and doing nothing.
Drag and drop a file system task into the Foreach Enumerator. Make it a Move file (or maybe it's rename) type. Use a Variable source and destination. The Source will be CurrentFile and the destination will be FolderOutput
I'm having a bit of trouble with AppleScript...
Long story short - what I'm trying to do is to do a function for every folder of parrentFolder containing someFile.
Basicaly, I have a complex folder structure with multiple folders ending up with a couple of files, within which (sometimes) there's a 'Preview.png' file. Now what I'm trying to do is to run a function that will go over each and every folder and whenever it finds 'Preview.png' within a folder it should store folder's path after which I can run a function to change the icon of that folder to a 'Preview.png' image. And it should loop over all of the folders in the main folder.
Anyone able to give me a hand?
Thanks,
Marko
On my "D:\" drive in Windows 7 I have a directory named "Downloads"
In this folder I have about 1400 folders with all kinds of funky/weird names with no real common denominator between them. What they do have in common is that they ALL contain one directory that has file contents.
Is there ANY way to either delete the root directories of those 1400 or so folders leaving only the subs (I need the one nested folder in there to remain intact name and content wise) OR is there any way to move every sub folder in those many directories just into "D:\Downloads" ? (I can shift select the 1400 useless directories and use the delete key afterwards.)
I'm slamming my face against the desk trying to figure this one out. Its going to take me DAYS to cut/paste all those little nested goobers into the downloads folder. I have VERY little programming experience (Basic on the TI-99/4A was as far as I got)
Thanks so much guys!
Crazy solution. Did a wildcard search in the downloads folder and sorted results by directory - was able to cut/paste all (1408) of the nested folders into the root!
So, is there a possible way to move Test.txt to C:\ProgramData\CsD2\Tools\("Unknown Folder Name")\data\per Using command prompt?
using foxidrives solution for your previous question for detecting the correct directory, then just
move test.txt "%folder%\"
Short answer: yes. Not quite sure what the situation is that has left only the middle part of your path unknown, and the need to use the comnand line, but I have encountered similar cases on Linux and expect the algoirthm can be adapted to Windows commands. It's possible to do this by hand rather than writing a shell script, but it's up to you and your skills.
Permissions matter. Make sure you elevate yours enough to read and write in Tools before continuing.
First, change directory to C:\ProgramData\CsD2\Tools\
Presumably there are many items here. Some may be "hidden," so list the contents of this directory and be sure to include an option to show hidden files and folders. If you can, restrict the search to directories only.
It's tempting to display contents recursively in the above step. It's up to you, but I find it makes the output cluttered without a script to do the rest of the work.
Now it's time to search for the subfolder set that theoretically only exists in your target folder. Suppose Tools contains the directories fldr1, fldr2, and fldr3. Use your command to list a directory's contents with the path "fldr1\data\per", then use "fldr2\data\per", and so on until it doesn't return an error. Per may be empty, but that should look different from the path not found error.
Now you've found the name of your mystery folder. Write it down for future reference.
At thus point, you know the path to Test.txt, and the full path to the destination directory. Do a move command to relocate Test.txt, and you're done. I like to relist the contents of the target directory after to be comfortable that it arrived.
I'm trying to run a batch file that exists in one folder, from a batch file in another folder:
Parent folder Big containes 2 folders BatchFolder and Medium.
BatchFolder contains a batch file called Batch1.
Medium contains another folder called Small.
Small contains a batch file called Batch2 that needs to run Batch1.
The command prompt is run from the location of Batch2
Therefor, how do I navigate up the folders To Big, and then navigate into the BatchFolder?
I've been trying alsorts to achieve this with no success, such as Bacth2 containing the following "call ../BatchFolder/Batch1.bat"
I'm not sure whether you really need to navigate to the required folder (i.e. set it as the current one) or you simply need a way to call the batch script in that folder using a relative path notation. Navigating, from how I understand the term, means the former, but your last sentence seem to show that you need the latter.
First, the answer:
call %~dp0%..\..\BatchFolder\Batch1.bat
Next, what it means. %~dp0% is a variation of %0: the latter is the full path to this batch file (i.e. Batch2.bat) including the file name, and the former is the full path to this batch's folder (including the trailing \).
.. points to the immediate parent folder. It is repeated twice because we need to access the 'grand-parent' of the Batch2.bat's folder, and the grand-parent is Big. Once we are pointing to Big, we can address the files/folders in it, in this case it's BatchFolder that we need, and eventually we can put the name of Batch1.bat.
This works regardless of what the current folder is. That is, in case I wasn't clear on that head, by simply calling a batch file you are not yet changing the current folder. You would have to use the CD command for that. That would be navigating (but I'm still open to being corrected as to my understanding of this term).