Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8130629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:47:13+00:00 2026-06-06T08:47:13+00:00

I have an application that creates invalid Directories… e.g. c:\Program Files\somedirectory. – the period

  • 0

I have an application that creates invalid Directories…
e.g. c:\Program Files\somedirectory. – the period is a part of the directory name.

Now, I have tried everything that I know about renaming a file in delphi.

  • RenameFile(file1,file2)
  • MoveFile(File1,File2)
  • etc…

I have tried getting the windows short path ExtractShortPathName but this just returns an empty string.
(to call in commandPrompt: “RENAME ShortOldName NewName”)

Now I know I can manually do it in cmd but I am not about to spend the time to go through all my files and do it 😉

Here is a bit of my code:

xshortname := ExtractFileName(ExtractShortPathName(ns + oldName));
  xNewName := newName;

  cmdTxt :=  PWideChar('/C cd ' + ns);
  cmdTxt2 := PWideChar(cmdTxt + '&&' + ' RENAME ' + xshortname + ' ' + #34 + xNewName + #34);
  ShellExecute(0, nil, 'cmd.exe', cmdTxt2, nil, SW_SHOWNORMAL);

I know shellExecute is not the best method to be using here.
I am just trying to get the stinker to work. I will worry about optimizing and proper Delphi coding later.

So my question is: Does anyone know of a function that will allow me to rename an invalid directory?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:47:16+00:00Added an answer on June 6, 2026 at 8:47 am

    You can use the standard Windows API function MoveFile() if you pass the name of the folder in a special way:

    MoveFile('\\?\D:\invalid_dir.', '\\?\D:\invalid_dir.fixed');
    

    instead of

    MoveFile('D:\invalid_dir.', 'D:\invalid_dir.fixed');
    

    More about it can be found on MSDN under the “Naming Files, Paths, and Namespaces” topic. Note that it specifically advises against putting trailing dots in file names.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application that creates bar graph based on inputs read from
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have a .Net application that dynamically creates a small HTML page and pops
Today we have a windows application that, using an OCX, creates a web page
I have created an application that uses settings.settings to store some user specific settings
I have created an application that records a series of longitude and latitude values
I have created an application server side that will create a pdf of a
I have a web application that allows users to create an account, and in
I have an Android application that uses the Android database to create tables and
I have a problem regarding Android App. I have created an application that download

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.