Members of Dirent structure

The structure, struct dirent refers to directory entry. http://www.gnu.org/software/libc/manual/html_node/Directory-Entries.html In linux it is defined as: struct dirent { ino_t d_ino; /* inode number */ off_t d_off; /* offset to the next dirent */ unsigned short d_reclen; /* length of this record */ unsigned char d_type; /* type of file; not supported by all file system … Read more

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

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,{‘.’,’..’})) = []; You shouldn’t do nameFolds(1:2) = [], since dir output from root directory does not contain those dot-folders. At least on Windows.

Copying a file from one directory to another with Ruby

Something like this should work. my_dir = Dir[“C:/Documents and Settings/user/Desktop/originalfiles/*.doc”] my_dir.each do |filename| name = File.basename(‘filename’, ‘.doc’)[0,4] dest_folder = “C:/Documents and Settings/user/Desktop/destinationfolder/#{name}/” FileUtils.cp(filename, dest_folder) end You have to actually specify the destination folder, I don’t think you can use wildcards.

How to use __dir__?

You can use __DIR__ to get your current script’s directory. It has been in PHP only since version 5.3, and it’s the same as using dirname(__FILE__). In most cases it is used to include another file from an included file. Consider having two files in a directory called inc, which is a subfolder of our … Read more

Is there a way to delete created variables, functions, etc from the memory of the interpreter?

You can delete individual names with del: del x or you can remove them from the globals() object: for name in dir(): if not name.startswith(‘_’): del globals()[name] This is just an example loop; it defensively only deletes names that do not start with an underscore, making a (not unreasoned) assumption that you only used names … Read more