Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My batch script receives a filename with full path (eg.: C:\...\file.c) as first argument. I need to get the directory of that file and go to the directory, much like:

cd C:\...\

How do I do this? How do I remove the filename from path? Going to C:\...\file.c throws an error.

share|improve this question
Possible duplicate of How to get folder path from file path with CMD. –  Andrew Morton May 11 '14 at 16:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.