in Education by
I want to include a batch file rename functionality in my application. A user can type a destination filename pattern and (after replacing some wildcards in the pattern) I need to check if it's going to be a legal filename under Windows. I've tried to use regular expression like [a-zA-Z0-9_]+ but it doesn't include many national-specific characters from various languages (e.g. umlauts and so on). What is the best way to do such a check? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
From MSDN's "Naming a File or Directory," here are the general conventions for what a legal file name is under Windows: You may use any character in the current code page (Unicode/ANSI above 127), except: < > : " / \ | ? * Characters whose integer representations are 0-31 (less than ASCII space) Any other character that the target file system does not allow (say, trailing periods or spaces) Any of the DOS names: CON, PRN, AUX, NUL, COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9 (and avoid AUX.txt, etc) The file name is all periods Some optional things to check: File paths (including the file name) may not have more than 260 characters (that don't use the \?\ prefix) Unicode file paths (including the file name) with more than 32,000 characters when using \?\ (note that prefix may expand directory components and cause it to overflow the 32,000 limit)

Related questions

0 votes
    What is the best possible way to check if a string can be represented as a number in Python? The ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    What is the best possible way to check if a string can be represented as a number in Python? The ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    Can someone tell me a method to check how can I represent a string as a number in Python? I am using this ... please help me with it. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    Can we check the existence of a file without using try statement in Python? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    How do I check whether a file exists without exceptions?...
asked Jan 9, 2021 in Technology by JackTerrance
0 votes
    If I issue the find command as follows: find . -name *.ear It prints out: ./dir1/dir2/earFile1. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 26, 2022 in Education by JackTerrance
0 votes
    You want to show file extensions in Windows operating system. How will you do so? Select the correct answer from above options...
asked Nov 28, 2021 in Education by JackTerrance
0 votes
    Given a string file path such as /foo/fizzbuzz.bar, how would I use bash to extract just the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    suppose I have passed : list=[] How can I check if a list is empty or not? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    Hey gys I want to purchase a gaming laptop »™ I need ur help gys » name some laptop under 30000 with good processor and ram and rom Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    Which of these methods of class String is used to check whether a given object starts with a particular ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    ……………… is a valid field name in access. a. position. b. message. c. day. Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
+1 vote
    What is true about variables 7Wonders is a valid variable name to give ? a) % is a valid first character for ... Variables are case sensitive c) ^US is a valid variable name...
asked Oct 8, 2020 in Technology by JackTerrance
0 votes
    I'm trying to download a collection of files, but the instructions are for the command line in Unix. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
...