@echo off
setlocal enabledelayedexpansion

rem set S=0
set /p S="The number of characters to be trimmed from the beginning of the file name: " %=%
rem set X=6
set /p X="The number of characters to be trimmed from the end of the file name: " %=%

set FOLDER_PATH=.
pushd %FOLDER_PATH%
for %%f in (*) do if %%f neq %~nx0 (
    set "filename=%%~nf"
    set "filename=!filename:~%S%,-%X%!"
    ren "%%f" "!filename!%%~xf"
)
popd
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            int y;

            Console.WriteLine("Developed by aripd.com\nThis program renames files in the same file path by removing first and last characters respectively given.\n\n");

            Console.Write("The number of characters to be trimmed from the beginning of the file name: ");
            x = int.Parse(Console.ReadLine());

            Console.Write("The number of characters to be trimmed from the end of the file name: ");
            y = int.Parse(Console.ReadLine());

            Console.WriteLine("Trimming first "+x+" and last " + y + " characters...\n");

            //Console.WriteLine(System.Reflection.Assembly.GetEntryAssembly().Location);
            //Console.WriteLine(new Uri(System.Reflection.Assembly.GetEntryAssembly().CodeBase).LocalPath);
            //Console.WriteLine(System.Reflection.Assembly.GetEntryAssembly().Location);
            //Console.WriteLine(Environment.GetCommandLineArgs()[0]);
            //Console.WriteLine(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);

            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@".");
            //System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@"C:\Users\Administrator\Desktop\test\");

            //foreach (System.IO.FileInfo file in dir.GetFiles("*.*"))
            foreach (System.IO.FileInfo file in dir.GetFiles("*.pdf"))
                {
                //System.IO.File.Move(file.FullName, file.FullName.ToString().Replace("abc_","");
                //Console.WriteLine("{0}", file.FullName);
                Console.WriteLine("{0}", file.Name);
                //Console.WriteLine("{0}", file.Name.Substring(x).Substring(0, file.Name.Substring(x).Length - y));
                //Console.WriteLine("{0}", System.IO.Path.GetFileNameWithoutExtension(file.Name));
                //Console.WriteLine("{0}", System.IO.Path.GetFileNameWithoutExtension(file.Name).Substring(x).Substring(0, System.IO.Path.GetFileNameWithoutExtension(file.Name).Substring(x).Length - y));
                //Console.WriteLine(file.Extension);
                //Console.WriteLine(file.DirectoryName + System.IO.Path.DirectorySeparatorChar);
                System.IO.File.Move(file.FullName, file.DirectoryName + System.IO.Path.DirectorySeparatorChar + System.IO.Path.GetFileNameWithoutExtension(file.Name).Substring(x).Substring(0, System.IO.Path.GetFileNameWithoutExtension(file.Name).Substring(x).Length - y) + file.Extension);
            }

            Console.WriteLine("\n\nCompleted. Press any key to close.");
            Console.ReadLine();

            /*
            Console.WriteLine("Press any key to continue or the Escape (Esc) key to quit: \n");

            do
            {
                cki = Console.ReadKey();
                Console.Write(" --- You pressed ");
                if ((cki.Modifiers & ConsoleModifiers.Alt) != 0) Console.Write("ALT+");
                if ((cki.Modifiers & ConsoleModifiers.Shift) != 0) Console.Write("SHIFT+");
                if ((cki.Modifiers & ConsoleModifiers.Control) != 0) Console.Write("CTL+");
                Console.WriteLine(cki.Key.ToString());
            } while (cki.Key != ConsoleKey.Escape);
            */
        }
    }
}