filenames

Create unique filename by adding incremental number

霸气de小男生 提交于 2019-12-12 18:54:32
问题 I'm trying to increment file names if a previously numbered one exists. For example, it should check if "Example.csv" exists. If so, the new file should be called "Example2.csv", then "Example3.csv", "Example4.csv" and so on. Here's my code so far: $fileNum = 2 ; The $month variable is defined earler in the script but I'll define another var for this example $month = "January" If FileExists("Emissions Log - " & $month & ".csv") Then If FileExists("Emissions Log - " & $month & $fileNum & ".csv

Choose File names automatically based on a calculation and then import them to python

一个人想着一个人 提交于 2019-12-12 18:39:36
问题 I have run into a wall where I don't know how to proceed further. I generate a lot of Raw Data from my CFD simulations. All the raw data will be in text format. The format of the text file will be "hA-'timestep'.txt" where A equals 0,1,2,3,4,5,6,7,8,9. For Eg h1-0500.txt will refer to data obtained along h1 at 500th time step.All the files of hA will be saved in a single folder. In my post processing, I want to import files at different flow times and do some analysis. I have written a code

PHP Regex for filename

不问归期 提交于 2019-12-12 18:25:46
问题 I made the user possible to change file names through a textarea, but now I'm having a regex problem. As I see for Windows 7, these characters only are not allowed for filenames: \ / : * ? < > | But I stubbornly, perhaps also wisely, choose to minimize the regex to ONLY these special characters: - _ . All the others should have to be cut. Can someone help me out with this regex? preg_replace all but: A-Za-z0-9 and - _ . I still really don't get the hang of it. 回答1: preg_replace('/[^A-Za-z0-9

Creation date in Windows CMD

若如初见. 提交于 2019-12-12 17:51:13
问题 Using Windows batch, this function returns creation dates of a file: :creationDate set "CompareFile=%~1" echo !CompareFile! for /f "skip=5 tokens=1,2,4,5* delims= " %%a in ('dir /a:-d /o:d /t:c') do ( if "%%~c" NEQ "bytes" ( if "%%~d"=="!CompareFile!" ( set "%~2=%%~a %%~b" ) ) ) goto:eof Example usage: call :creationDate "!MyFile!" MyFileCreationDate echo !MyFile! was made on !MyFileCreationDate! The Variables in the function: %%~a = Creation Date %%~b = Creation Time %%~d = Filename (error

What is the naming convention for CMake scripts?

时光总嘲笑我的痴心妄想 提交于 2019-12-12 16:12:11
问题 I know that CMake makes use of the standard name "CMakeLists.txt" and the add_subdirectory function for calling scripts directly in the build process. I have some CMake code that I use to turn files into C++ strings that can then be baked into the program using #include directives. The relevant code in my root CMakeLists file looks like this (greatly simplified, of course): add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/path/to/example.json.txt COMMAND ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR} $

Java GetFile returns incorrect filename after using SetFile

♀尐吖头ヾ 提交于 2019-12-12 16:09:50
问题 I have some Java code: public static String getSaveFilePath(String title2) { FileDialog fd = new FileDialog(new Frame(), "Save As...", 1); fd.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".mp3"); } }); fd.setFile(title2 + ".mp3"); fd.setVisible(true); String str3 = fd.getFile(); String str4 = fd.getDirectory(); if (str4 == null) return null; str3 = str3.replace(".mp3", ""); str3 = str3 + ".mp3"; String str5 = str3; File localFile

Expand a relative path in Ant script, for Inkscape

此生再无相见时 提交于 2019-12-12 12:33:11
问题 I'd like to write an Ant script that calls an external utility (Inkscape, in fact) that needs a full path. Right now I have <exec executable="${inkscape.path}"> <arg value="--file=build_exe/splash.svg" /> <arg value="--export-png=build_exe/splash.png" /> <arg value="-C" /> </exec> On Windows, Inkscape requires absolute paths. So how can I coax Ant to make build_exe/filename into an absolute path for me? Or, alternately, is there a workaround for Inkscape (maybe setting the working directory)?

Change file name suffix(es) (using sed ?)

独自空忆成欢 提交于 2019-12-12 12:04:29
问题 I'd like to change the file name suffix from files (using a bash script), but sometimes there are files with one period and some with two. Now I use this: new_file=`echo ${file} | sed 's/\(.*\.log.*\)'${suf}'/\1.'${num}'/'` Where 'new_file' is the new file name, 'file' the original file name, '${suf}' the file's suffix and ${num} a new number. So some.log must become some.log.1 and some.log.1 must become some.log.2 . With my code some.log becomes some.log.1 , but some.log.1 remains some.log.1

RegEx pattern to limit dashes in these circumstances

∥☆過路亽.° 提交于 2019-12-12 11:19:26
问题 Scenario I'm using a 3rd party file renaming software which is written in Delphi and has pascal-script support: http://www.den4b.com/?x=products&product=renamer The application allows the usage of regular expressions to rename files. this means that if what I need to do with a filename cannot be accomplished only using one RegEx, then I could use simultaneous various expressions or also a pascal-script code to accommodate the filename until I can properly format the filename for the needs of

Maximum Possible File Name Length in Windows Kernel

谁说我不能喝 提交于 2019-12-12 11:13:00
问题 I was wondering, what is the longest possible name length allowed by the Windows kernel? E.g.: I know the kernel uses UNICODE_STRING structures to hold all object paths, and since the byte length of a wide-character string is stored inside a USHORT , that allows for a maximum path length of 2^15 - 1 characters. Is there a similar, hard restriction on a file name (rather than path)? (I don't care if NTFS or FAT32 imposes a particular restriction; I'm looking for the longest possible