Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 months ago.
Improve this question
I have a folder with many subfolders (subfolder1). Under each subfolder1 is another subfolder (subfolder2) containing files. I want to remove the first level of subfolder1 so that all I have is subfolder2 and subfolder2s contents.
So I guess it would work by moving subfolder2 plus contents to a new folder, thereby removing the subfolder1 from the folder structure.
There are 1000s of subfolder1s to be removed from this folder structure.
Any advice would be greatly appreciated.
Kind Regards,
Martina
I haven’t been able to figure it out. Powershell beginner.
You could get all child items of each first level subfolder and move each one of this childs one level up and then delete the empty first level folder shells. Test on a test folder structure before using on your files:
$files = Get-ChildItem “c:\folder\base”
Get-ChildItem $files | Move-Item -Destination { $_.Directory.Parent.FullName }
$files | Remove-Item -Recurse
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed last year.
Improve this question
I have a simple script which closes an open window of "wallpaper engine" using its own arguments and then another line calls for the next wallpaper inside a folder:
1803613842
How can i pick the next wallpaper from a random folder instead of calling a specific one?
#echo
"C:\Program Files (x86)\Steam\steamapps\common\wallpaper_engine\wallpaper64.exe" -control closeWallpaper "Wallpaper #$"
"C:\Program Files (x86)\Steam\steamapps\common\wallpaper_engine\wallpaper64.exe" -control openWallpaper -file "C:\Program Files (x86)\Steam\steamapps\workshop\content\431960\1803613842\project.json" -playInWindow "Wallpaper #2" -width 1920 -height 1080
exit
The first step is to make a bash array of all the folder names which are available.
Once you have an array (here caled #dirs), you can pick a random item as follows:
randomdir=${dirs[$RANDOM % ${#dirs[#]} ]}
This generates a random number between 0 and the length of the array, and then returns the element at that index.
If you can get a comma-separated or similar list of directories, you can create the dirs array by doing:
my_dirs="abc,def,ghi"
IFS=',' read -ra dirs <<< "$my_dirs"
randomdir=${dirs[$RANDOM % ${#dirs[#]} ]}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
Related to this -- https://stackoverflow.com/questions/21487257/a-perl-cgi-script-for-uploading-files -- question, I have another one: can this:
http://www.seaglass.com/file-upload-pl.html
script be modified so that it would accept different input files and save them as different output files, and not just overwrite the single output file?
I'm new to Perl/CGI, so I wouldn't see an obvious answer.
In $basename you already have name of the file. You do not have to write the uploaded file into /tmp/outfile; you can construct the path dynamically, depending on $basename.
Create a directory where you want to place the files. I assume it will still be C:\tmp. Instead of
open(OUTFILE, ">/tmp/outfile")
write
open(OUTFILE, ">/tmp/$basename")
and it should work. Taint is removed from $upfile inside GetBasename(), even before $basename is created. But this is not safe, still. Before giving it to open(), you should remove all unwanted characters from the file name, e.g.
$basename =~ s/[^A-Za-z0-9_.-]//g;
$basename =~ s/^[^A-Za-z0-9]*//;
If $basename is empty now, you have to chose a name other way. Also if file of the same name already exists, you have to choose whether you want to overwrite it or make up a unique name. My current solution just overwrites.
If you want to know more about regular expressions, look at perlre manual page.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I'm paying high price for not organising my mp3 files on regular basis.
There are three big steps I need to take and without automation they are a nightmare.
1 . Organise folders (so far I moved all mp3 folders to one location):
G:/Music/New Folder/artist/ (1000 files here)
G:/Documents/Music/mp3/ (1000 files here)
G:/New Folder/Music/new/ (1000 files here)
and so on, you got the idea
So, what I'm looking for is a way I can move all the mp3 files from folders/subfolders/ to one G:/Sorted Music folder.
2 . Take the
filename "01 - ABBA - Waterloo", Title: "Waterloo", Artist: "Unknown" and make it
filename "ABBA - Waterloo", Title: "Waterloo", Artist: "ABBA", deleting every other attribute/field at the same time ("Album", "Contributing Artist", "Comments" etc.)
3 . Having mp3 files all in one place, and all in the same format, divide them into folders:
Sorted Music/Artist/ (files here)
Sorted Music/Artist/ (files here)
For points 2 and 3(especially) I downloaded Mp3tag v2.54. However, because of the "01" in the filename, it "misextracts" information from filename to put into tags. And because of "Unknown" for the artist, it won't make the filename right.
Any useful tips will be appreciated.
If your files have a similar name. ANYTHING - BAND - TITLE then this should be no problem. You can use Autoit3 to organize your files and set and get the mp3 tags.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
When executing a C-program, we have to type a '.' token and a '/' token together followed by our program name:
./program
What do each of the these tokens mean? Why do they need to be together to work?
The ./ syntax just refer to the current directory (Actually . is the current directory while / is the path separator). This is needed because the shell will look into folders specified in $PATH environment variable for executables. Since the program is in the current directory which is not inside PATH by default you need to specify the folder you are running it from.
Actually, this has nothing to do with C. This value is simply passed along to the operating system and used to locate a file.
But on Windows, it doesn't appear to have much meaning at all. . is the current directory and the / is simply the path separator between the current directory and program. Since the OS defaults to the current directory, it refers to the same path as just program.
. means current path
.. means parent.
/ means root or path separator. Depends on Unix/Windows/Mac
./ means current path and relates, towards RHS.
./Program means PWD and Program as Directory or Location.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have some zipped plug-ins, when I try to unpack that the unpacking fails. When I looked deep into it I found that the some of the files are exceeding 256 characters, which I guess is not allowed in WINDOWS operating system.
So my question is there any way to find out if any file name inside a particular folder exceeds 256 characters?
I'm using WINDOWS XP operating system.
Thanks in advance!!
Anand
Without having your zip file is a bit harder to find out if the problem is exactly what you said... AFAI remember, 7zip would truncate the long file names, not "not extract" them. But I don't have any zip with long names to test.
I'd try some things:
Open the zip file with 7zip and try to rename the long names, instead of extracting them.
Try to open the zip file with other zip app, like (izarc)[http://www.izarc.org/news.html], and rename the files
If you don't have access to another computer, try to use one of the available online unzippers. For example: http://jcarleemae.wen.ru/extract.html