When running:
New-Folder -Name myFolder -Location (Get-Folder -NoRecursion)
it creates a root folder under "Hosts and clusters"... How do I create a root folder under the Datastores Tab?
Thank you!
To do this, you'll need to reference the hidden (from UI) 'datastore' folder object. You can do this with the following code:
New-Folder -Name myFolder -Location (Get-Folder -Name datastore)
Similarly, you can do the same thing when you need to create Host or Network folders.
Related
I have a multiple folders with different names: folderA, FolderB etc.
Within each of these folders are multiple files: fileA, fileB, fileC etc.
I want to search through all these folders and copy only specific files to a new location but with the same parent folder name: e.g. I want to generate:
new_location/folderA/fileA
new_location/folderA/fileC
new_location/folderB/fileA
new_location/folderB/fileC
Could anyone suggest the unix commands that would accomplish this?
Thanks
Rob
This depends somewhat, on how you can or do specify your specific files.
find folderA folderB folderC -type d -exec mkdir -p new_location/{} \;
will should make the proper subdirectories
find folderA folderB folderB -name somepattern -exec cp {} new_location/{} \;
may or may not need to worry about an extra "/" depending on directory names, etc
How do I use robocopy so the root contents are not copied?
I already have root files stored elsewhere and I just would like to copy the sub directories and their contents while the source folder still containing root directory contents.
This is not possible with native robocopy switches as far as I can tell. You will need to use a script to enumerate the subdirectories and run robocopy against them.
Here is a sample PowerShell command that will accomplish what you want, copying everything from C:\temp\source\ to c:\temp\target\, excluding the files that are in c:\temp\source:
get-childitem c:\temp\source\* |?{$_.PsIsContainer} | %{robocopy $_.FullName c:\temp\target\$($_.Name) /S}
Credit to powershell ignore files in root but robocopy folders and their contents for the basics of this.
I don't have a reputation but the answer Mr. Hinkle gave solved 2 days of effort and searching. My challenge was moving the files that were > 1hour of age. This combination of powershell and robocopy appears to work. Below is my final code.
# Clear screen
cls
# Disconnect the drive if it exist - don't know where it is pointing to
If (Test-path p:) {
net use p: /delete
}
#Map the destination
net use p: \\server\dir1\dir2\dir3 password /USER:domain\user /P:no
get-childitem -path 'D:\dir1\dir2\' |
where-object {$_.LastWriteTime -lt (get-date).Addhours(-1)} |
?{$_.PsIsContainer} |
%{robocopy $_.FullName p:\$($_.Name) /S /MOVE /r:3 /W:1}
net use p: /delete
I am using Brackets Release 1.4 and have a question. I cannot figure out how to "Add a new file" to the top level (root) folder. It will allow me to add new files to sub folders. A lot of tutorials that use Brackets tell you to 'Add' a new file in the root folder, but I cannot get Brackets to do this. What am I doing wrong?
Assuming you are on Windows, you can for example use the Command Prompt, cd into your root folder and then create the file with the touch command.
Here are some basic terminal commands:
http://masteruby.github.io/productivity-booster/2014/03/26/top-ten-commands-in-terminal-you-will-use-everyday.html
Or you could go to file -> New... and then, save as... to save the file in the folder of your liking.
I'm attempting to open a directory in Unix. If I enter the command
ls
I see the directory listed in my current directory but if I endter
cd [directory_name]
I get the error
No such file or directory
I'm also not able to auto complete the directory name using the 'tab' key. Does anyone know what may be causing this?
Check whether you are using the right capitalization? It's case sensitive. Add this to your ~/.inputrc if you want bash to not care about the case of the file.
set completion-ignore-case on
This is example:
user#stackoverflow:~$ ls
users questions file.txt
user#stackoverflow:~$ cd /questions
user#stackoverflow:~/questions$
Make sure that you're trying to access a valid folder and not a file.
To further explain:
List the current directory's contents (either one):
ls .
ls
List the home directory's contents (wherever you are):
ls ~
List the root directory's contents (wherever you are):
ls /
I want to symlink:
/var/www/ThisFolder
to this folder
/var/www/htdocs/Thisfolder
I.e Symlink the folder that is in a non web accessible directory to link to one that is.
I plan to do this via:
ln -s /var/www/ThisFolder /var/www/htdocs/Thisfolder
Will my server then treat the folder outside the root as if it were inside the root?
Permissions on symbolic links are kind of funny. If you don't have permissions to view your target folder (/var/www/htdocs/Thisfolder) you wont be able to access it through the symlink. The permissions you will see by doing an ls -l on your symlink will show its permissions for renaming/unlinking the symlink, not for the target.