directory

Getting all file names at a given folder name

我与影子孤独终老i 提交于 2019-12-30 06:03:09
问题 How can I get the names of files in a given folder name at Matlab? 回答1: You should use the dir function. Like so: allFiles = dir( 'c:\my\folder' ); allNames = { allFiles.name }; 回答2: If you're on linux you can call the find command and process the output. find allows for much more advanced features than just using dir , and can be called using system('find path') . 来源: https://stackoverflow.com/questions/5803915/getting-all-file-names-at-a-given-folder-name

How to recursively traverse a directory tree and find only files?

安稳与你 提交于 2019-12-30 05:27:04
问题 I am working on a scp call to download a folder present on a remote system. Downloaded folder has subfolders and within these subfolders there are a bunch of files which I want to pass as arguments to a python script like this: scp -r researcher@192.168.150.4:SomeName/SomeNameElse/$folder_name/ $folder_name/ echo "File downloaded successfully" echo "Running BD scanner" for d in $folder_name/*; do if [[ -d $d ]]; then echo "It is a directory" elif [[ -f $d ]]; then echo "It is a file" echo

VB 2010: How to copy all subfolders of a folder in an other folder?

隐身守侯 提交于 2019-12-30 05:16:05
问题 I got a question in Visual Basic 2010: How can I copy all subfolders (only the subfolders, not the main folder) into another folder? Thanks for the help! 回答1: You need to recursivly iterat through all the files and folders and copy them. This method do the job for you: Public Sub CopyDirectory(ByVal sourcePath As String, ByVal destinationPath As String) Dim sourceDirectoryInfo As New System.IO.DirectoryInfo(sourcePath) ' If the destination folder don't exist then create it If Not System.IO

Good reasons to pass paths as strings instead of using DirectoryInfo/FileInfo

谁说我不能喝 提交于 2019-12-30 03:49:05
问题 In my new code I am not using strings to pass directory paths or file names. Instead I am using DirectoryInfo and FileInfo as they seem to encapsulate a lot of information. I have seen a lot of code that uses strings to pass directory information then they "split" and "mid" and "instr" in long incomprehensible statements until they get the part of the directory they are looking for. Is there any good reason to pass paths as strings? 回答1: In general, I think keeping the information in FileInfo

What is the difference between a source folder and a (normal) folder

纵饮孤独 提交于 2019-12-30 01:54:04
问题 I'm following this guide: Spring MVC and I realized that I do not know the difference between a source folder (src) and a plain folder. I'm using eclipse, so maybe the difference is only useful in an IDE? Also, I've noticed that java classes tend to go in src folders; whilst every other file goes into a plain folder (or the project root folder). So, What is the significance of the source folder (src)? Why use a source folder over a plain folder? Thanks! 回答1: A source folder is marked by

list the subfolders in a folder - Matlab (only subfolders, not files)

核能气质少年 提交于 2019-12-29 20:40:23
问题 I need to list the subfolders inside a folder using Matlab. If I use nameFolds = dir(pathFolder), I get . and .. + the subfolder names. I then have to run nameFolds(1) = [] twice. Is there a better way to get the subFolder names using Matlab? Thanks. 回答1: Use isdir field of dir output to separate subdirectories and files: d = dir(pathFolder); isub = [d(:).isdir]; %# returns logical vector nameFolds = {d(isub).name}'; You can then remove . and .. nameFolds(ismember(nameFolds,{'.','..'})) = [];

How to move all files with specific extension from all subdirectories to their parent using CMD?

匆匆过客 提交于 2019-12-29 20:33:22
问题 Folder c:\folder1 contains subfolder1 , subfolder2 , etc.. These subdirectories hold .pdf and .db files. How can all the .pdf files be moved to c:\folder1 using the Windows command interpreter? 回答1: This worked for me: for /r "c:\source_directory\" %%x in (*.pdf) do move "%%x" "c:\target_directory\" This command will copy recursively al pdf files from source to target directory using cmd in windows 7 - tested and works. Hope it helps. 回答2: The outer for loop lists the sub-directories in the

Difference between Package and Directory in Java

﹥>﹥吖頭↗ 提交于 2019-12-29 19:18:18
问题 In a Java Project , does keeping all the .java files in the same folder mean they are in the same package? What is the difference in making a Package for our project compared to keeping all the project files in one folder? This thread doesn't really address my question. 回答1: There is a relationship between package and directory, but it's one that you must maintain. If you have a class that's in "mypackage1.mypackage2", that means that the java command is going to expect to find it in a

Difference between Package and Directory in Java

*爱你&永不变心* 提交于 2019-12-29 19:17:31
问题 In a Java Project , does keeping all the .java files in the same folder mean they are in the same package? What is the difference in making a Package for our project compared to keeping all the project files in one folder? This thread doesn't really address my question. 回答1: There is a relationship between package and directory, but it's one that you must maintain. If you have a class that's in "mypackage1.mypackage2", that means that the java command is going to expect to find it in a

How to overwrite a folder if it already exists when creating it with makedirs?

半城伤御伤魂 提交于 2019-12-29 13:44:14
问题 The following code allows me to create a directory if it does not already exist. dir = 'path_to_my_folder' if not os.path.exists(dir): os.makedirs(dir) The folder will be used by a program to write text files into that folder. But I want to start with a brand new, empty folder next time my program opens up. Is there a way to overwrite the folder (and create a new one, with the same name) if it already exists? 回答1: import os import shutil dir = 'path_to_my_folder' if os.path.exists(dir):