dir

walking along and processing files in directory in python

僤鯓⒐⒋嵵緔 提交于 2019-11-30 19:01:38
问题 I have huge data in a directory tree format like: c:/user/name/class/std/section I to VI [all section has individual folder i.e. 6 folder in total and all folder have 100+ files to be processed] I wrote a script in which if I give the folder containing the files e.g. Section I then it would process files inside using glob.iglob function. Is it possible to write a script which can walk along directories by just entering one directory > processing file > leaving directory > entering different

Strange Windows DIR command behavior

不羁岁月 提交于 2019-11-30 11:19:13
I discovered this quite by accident while looking for a file with a number in the name. When I type: dir * number * (where number represents any number from 0 to 9 and with no spaces between the asterisks and the number) at the cmd.exe command prompt, it returns various files do not appear in any to fit the search criteria. What's weird, is that depending on the directory, some numbers will work and not others. An example is, in a directory associated with a website, I type the following: dir *4* and what is returned is: Directory of C:\Ampps\www\includes\pages 04/30/2012 03:55 PM 153

How to use __dir__?

早过忘川 提交于 2019-11-30 06:10:56
I want to use __dir__ . However, I can't find any good tutorial on how to set it up. I have my htdocs in Dropbox. Does it work something like this? define(__DIR___, 'd:documents/dropbox/yolo/swag/htdocs/myproject/test/newtest/ testphp/test_new/testincludes/1/new_folder/') That is the directory where my project is located and it has sub folders. I want to include a file into another file that is in the parent folder. Should I then just type: include'__DIR__/warlock.php'; Or do I have to type something like this? include '___DIR__/wow/newb/guidesfornabz/classes/casters/warlock.php'; You can use

Strange Windows DIR command behavior

左心房为你撑大大i 提交于 2019-11-29 16:58:55
问题 I discovered this quite by accident while looking for a file with a number in the name. When I type: dir * number * (where number represents any number from 0 to 9 and with no spaces between the asterisks and the number) at the cmd.exe command prompt, it returns various files do not appear in any to fit the search criteria. What's weird, is that depending on the directory, some numbers will work and not others. An example is, in a directory associated with a website, I type the following: dir

How to rename a file in Ruby?

时光总嘲笑我的痴心妄想 提交于 2019-11-28 17:23:45
Here's my .rb file: puts "Renaming files..." folder_path = "/home/papuccino1/Desktop/Test" Dir.glob(folder_path + "/*").sort.each do |f| filename = File.basename(f, File.extname(f)) File.rename(f, filename.capitalize + File.extname(f)) end puts "Renaming complete." The files are moved from their initial directory to where the .rb file is located. I'd like to rename the files on the spot, without moving them. Any suggestions on what to do? What about simply: File.rename(f, folder_path + "/" + filename.capitalize + File.extname(f)) Doesn't the folder_path have to be part of the filename? puts

Working with Unicode file names in VBA (using Dir, FileSystemObject, etc.)

好久不见. 提交于 2019-11-28 12:09:38
I am iterating through files in a folder (which means I do not know the names in the folder), and have a file with a Polish ł character. The Dir function converts this to an l which means the filename can't be found at a later date. I've declared the var that I'm assigning the dir value to as a string. I've also tried FSO and getfolder which also has the same issue. I've also noticed the file dialog (set to folder select mode) converts the character above too. Is this a bug, or is it something that can be worked around? It sounds like you are being misled by the fact that while VBA itself

File searching in VBA

ε祈祈猫儿з 提交于 2019-11-28 08:44:54
问题 I wrote a vba code that browse all path folder and search for "strings.xml" file. Dim oFS As Office.FileSearch Dim i As Integer Set oFS = Application.FileSearch With oFS .NewSearch .FileType = msoFileTypeAllFiles .Filename = "strings.xml" .LookIn = "D:\Workspace" .SearchSubFolders = True .Execute MsgBox "Finish ! " & .FoundFiles.Count & " item found !" End With However, in my workspace I have many "strings.xml" files that this current code locates and but I only want to find the "strings.xml"

Recursive Copy of Directory

别来无恙 提交于 2019-11-28 06:53:05
On my old VPS I was using the following code to copy the files and directories within a directory to a new directory that was created after the user submitted their form. function copyr($source, $dest) { // Simple copy for a file if (is_file($source)) { return copy($source, $dest); } // Make destination directory if (!is_dir($dest)) { mkdir($dest); $company = ($_POST['company']); } // Loop through the folder $dir = dir($source); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Deep copy directories if ($dest !== "$source/$entry")

How do I read a directory as a file in Unix?

我的梦境 提交于 2019-11-28 06:36:33
问题 I understand that a directory is just a file in unix that contains the inode numbers and names of the files within. How do I take a look at this? I can't use cat or less on a directory, and opening it in vi just shows me a listing of the files...no inode numbers. 回答1: Since this is a programming question (it is a programming question, isn't it?), you should check out the opendir , readdir and closedir functions. These are part of the Single UNIX Spec. #include <sys/types.h> #include <dirent.h

Members of Dirent structure

元气小坏坏 提交于 2019-11-28 06:24:15
I have started working with dirent.h library and I came across a very useful member of "struct dirent" structer which struct dirent *p->d_name in my book. But unfortunatly it doesn't states any other members of this structure; I was wondering what else are the members of this structure and what are they used for? Regards 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; /*